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

Should theme_void() include paper argument? ink argument not working with geoms #6251

Open
EvaMaeRey opened this issue Dec 18, 2024 · 5 comments

Comments

@EvaMaeRey
Copy link

Thank you for the excellent work in the theming arena! 🚀

Just opening an issue to note that having the 'paper' argument for theme_void() might be misleading.

It also seems that the ink declaration doesn't seem to propagate to the geoms.

library(ggplot2)
p <- ggplot(mtcars, 
            aes(x = factor(cyl), 
                fill = factor(cyl))) +
  geom_bar() + 
  geom_point(stat = StatCount, size = 7) + 
  geom_tile(aes(y = -2, fill = NULL))

p +
  theme_void(ink = "plum", paper = "cornsilk", base_size = 18)

last_plot() + 
  theme(geom = element_geom(ink = "plum"))

Created on 2024-12-18 with reprex v2.1.0

@clauswilke
Copy link
Member

Is the problem that theme_void() doesn't have a background element at all and is fully transparent? I think the first question is whether this theme should respond to the paper setting. My sense is it should. We could address this while keeping backwards compatibility (I hope) by adding a background element and giving it a fill color of full transparency.

@EvaMaeRey EvaMaeRey changed the title theme_void() should not include paper argument, ink argument not working Should theme_void() should include paper argument? ink argument not working with geoms Dec 18, 2024
@EvaMaeRey EvaMaeRey changed the title Should theme_void() should include paper argument? ink argument not working with geoms Should theme_void() include paper argument? ink argument not working with geoms Dec 18, 2024
@teunbrand
Copy link
Collaborator

I recommend the following for transparent paper, as in theme_transparent():

ink = "black", paper = alpha(ink, 0)) {

It prevents some interpolation artefacts. @EvaMaeRey is there any chance you're interested in preparing a PR for this? 😁

@EvaMaeRey
Copy link
Author

Yes. I'd only lean towards a theme that looks like theme_void (remove axes and gridlines), but is fully opaque, white paper as a default, called something like theme_blank(), theme_void2(), or theme_poster(). Reading p + theme_transparent(paper = "blue") still seems like it should still be transparent somehow.

@teunbrand
Copy link
Collaborator

teunbrand commented Dec 18, 2024

If we adopt Claus' solution of setting a background element (i.e. plot.background), then an opaque version would be as easy as setting theme_void(paper = "white"). I don't think an opaque variant merits a separate theme in this case.

@EvaMaeRey
Copy link
Author

EvaMaeRey commented Dec 18, 2024

I like Claus' proposal, setting plot.background element - and paper default of alpha(ink, 0). I guess the main worry is backward compatibility issues. Could we revisit introducing a new theme (and naming and default decision), if compatibility issues arise?

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

3 participants