Skip to content

Support grid = "x/y/X/Y"#578

Merged
grantmcdermott merged 13 commits intomainfrom
fine_grid
May 8, 2026
Merged

Support grid = "x/y/X/Y"#578
grantmcdermott merged 13 commits intomainfrom
fine_grid

Conversation

@grantmcdermott
Copy link
Copy Markdown
Owner

@grantmcdermott grantmcdermott commented May 8, 2026

Closes #577
Closes #193

Also makes it easy to add only vertical or horizontal grid lines, which opens up support for some new themes... e.g. broadsheet publications like Financial Times, Economist, etc. tend to use single axis grid lines in all of their plots.

Some examples:

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

plt(wt ~ mpg | factor(cyl), mtcars, grid = 'xy')

plt(wt ~ mpg | factor(cyl), mtcars, grid = 'xY')

plt(wt ~ mpg | factor(cyl), mtcars, grid = 'Y')

And, of course, the main attraction is using a finer grid for certain themes. Here's a riff on our proposed improvements to the "ipsum" theme in #409.

tinytheme(
  "ipsum", family = "Arial Narrow", font.main = 2, font.sub = 1, cex.lab = 0.8,
  palette.qualitative = c("#D18975", "#8FD175", "#3F2D54", "#75B8D1", "#2D543D", "#C9D175", "#D1AB75", "#D175B8", "#758BD1"),
  tcl = -0.0,  mgp = c(1.5, 0.5, 0) - c(0.0+0.1, 0.1, 0),
  grid = "xy"
)

plt(
  wt ~ mpg | factor(cyl), mtcars,
  xlab="Fuel efficiency (mpg)", ylab="Weight (tons)", 
  main="Seminal tinyplot scatterplot example",
  sub="A plot that is only useful for demonstration purposes"
)

tinytheme()

Created on 2026-05-07 with reprex v2.1.1

@grantmcdermott grantmcdermott changed the title Support `grid = "x/y/X/Y" Support grid = "x/y/X/Y" May 8, 2026
@grantmcdermott

This comment was marked as outdated.

@grantmcdermott
Copy link
Copy Markdown
Owner Author

Okay, I think I've managed to catch all remaining edge cases and simultaneously fix a minor, but long-standing bug (#193).

@grantmcdermott grantmcdermott merged commit bb3fee8 into main May 8, 2026
3 checks passed
@grantmcdermott grantmcdermott deleted the fine_grid branch May 8, 2026 19:17
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.

Finer panel grid lines grid = grid() not working properly with faceted plots

1 participant