Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend Key Size parameter only changes text's size, not symbols' #475

Open
Felixmil opened this issue Aug 7, 2023 · 1 comment
Open

Comments

@Felixmil
Copy link
Contributor

Felixmil commented Aug 7, 2023

When changing theme's legend.key.size, it does not have any effect on the legend keys sizes:

library(tlf)
emptyPlot <- initializePlot()
scatterPlot <- addScatter(x = c(1, 2, 3), y = c(1, 2, 3))

scatterPlot + ggplot2::theme(legend.key.size =  ggplot2::unit(1, "pt"))

scatterPlot + ggplot2::theme(legend.key.size =  ggplot2::unit(10, "pt"))

Created on 2023-08-07 with reprex v2.0.2

@Felixmil
Copy link
Contributor Author

Felixmil commented Aug 7, 2023

Similar result is obtained when using {ospsuite}. This is because LegendKeySize is actually not related to keysize in tlf.

In default-plot-configuration.R

...
    legendKeysSize = tlf::PlotAnnotationTextSize$plotLegendCaptionSize,
    legendKeysColor = "black",
    legendKeysFontFamily = "",
    legendKeysFontFace = tlf::FontFaces$plain,
    legendKeysAngle = 0,
    legendKeysAlign = tlf::Alignments$left,
..

in utilities-plotting.R:

  legendKeysFont <- tlf::Font$new(
    size = generalPlotConfiguration$legendKeysSize,
    color = generalPlotConfiguration$legendKeysColor,
    fontFamily = generalPlotConfiguration$legendKeysFontFamily,
    fontFace = generalPlotConfiguration$legendKeysFontFace,
    angle = generalPlotConfiguration$legendKeysAngle,
    align = generalPlotConfiguration$legendKeysAlign
  )

So changing the legendKeys related settings will actually affect what is defined as legend.text in {ggplot2} instead of legend.key.

So I would do 3 things here:

  1. Rename the legendKeys... properties to legendText...
  2. Add legendKeys properties (size, but also width and height to solve Spacing between legend entries and between the symbol and the text is too big. esqLABS/esqlabsR#508)
  3. Make these properties accessible from OSPSuiteR

@Yuri05 Yuri05 removed the type: bug label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants