Skip to content

Conversation

@grantmcdermott
Copy link
Owner

@grantmcdermott grantmcdermott commented Jul 20, 2025

Fixes #434.

@zeileis I followed your suggestion by adding a bit of extra space at the end of each legend label, so that they are closer to their own respective keys (rather than being equidistant between keys). Example:

pkgload::load_all("~/Documents/Projects/tinyplot")
#> ℹ Loading tinyplot
tinytheme('clean2')

aq = transform(
  airquality,
  Month = factor(month.name[Month], levels = month.name[5:9])
)

plt(Temp ~ Day | Month, data = aq, legend = "bottom!")

As part of this PR, I also addressed some limitations that we had w.r.t. to multicolumn legend support. These should work much better now and also provide an escape hatch for cases with many discrete labels that would otherwise overflow the plot region. I added an example to the "Tips & tricks" vignette along these lines.

plt(
  weight ~ Time | Chick,
  data = ChickWeight,
  legend = list(ncol = 3),
  type = "l"
)

Created on 2025-07-19 with reprex v2.1.1

@grantmcdermott grantmcdermott merged commit 49cc2d5 into main Jul 20, 2025
3 checks passed
@grantmcdermott grantmcdermott deleted the horiz_legend_gap branch July 20, 2025 01:02
@zeileis
Copy link
Collaborator

zeileis commented Jul 20, 2025

Looks great, thanks! 🎉

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

Successfully merging this pull request may close these issues.

Better default spacing for horizontal legends

3 participants