Conversation
jemus42
left a comment
There was a problem hiding this comment.
Why does vistool_theme() return an object of class vistool_theme rather than "just" a ggplot2 theme?
Is there a benefit to starting from scratch like this and defined a different class rather than starting from a ggplot2::theme()?
See for example how other packages define ggplot2 themes:
- https://github.com/jrnold/ggthemes/blob/d87e5deebc6ac4902da1a1a25aa00ed081a32567/R/fivethirtyeight.R#L10-L37
- https://github.com/hrbrmstr/hrbrthemes/blob/d3fd02949fc201c6db616ccaffbb9858aec6fd2b/R/theme-ipsum.r#L72-L171
My suggestion would be to define a theme_vistool() (canonically the naming schemes is theme_xyz() for ggplot2 themes) which uses ggplot2's themeing functions alone, unless you have a different plan?
For other plotting systems like plotly we'd need a bespoke solution I guess, but a one-size-fits-all solution would be hard, if at all possible.
|
Currently, |
|
Ah yes, checks out. From the perspective of "we want a default ggplot2 theme for plots on lecture slides, even for non-vistool plots" I'd still prefer to have a "normal" ggplot2 theme exported from the package, so people can just do Supporting ggplot2 and plotly at the same time might be a bit counter-intuitive, I'd recommended two distinct theme functions, one for ggplot2 and one for plotly, which under the hood of course might rely on the same values, so there's no duplication / copy paste hell hopefully, does that make sense? |
|
What's the status here? I see
|
|
Sorry for the late reply - both are implemented now. Please take another look :) |
|
Sorry for the late reply as well 🥴 I see the automatic palette setting works now, cool! library(vistool)
library(ggplot2)
getOption("vistool.theme")
#> $palette
#> [1] "viridis"
#>
#> $text_size
#> [1] 11
[...]
p <- ggplot(mtcars, aes(x = wt, y = mpg, color = factor(vs))) +
geom_point() +
theme_vistool()
pp +
theme(
palette.colour.discrete = scales::pal_viridis(
option = "H",
begin = 0.2,
end = 0.8
)
)Created on 2026-01-27 with reprex v2.1.1 Not sure what to do here ideally, maybe it's worth switching scales for the discrete case, such as RColorBrewer's
Which I believe has a good "reputation" in terms of accessibility. The scico palettes could also be useful, primarily in case we need diverging scales (with a neutral mid-ppoint, e.g. 0, and then clearly distinguishable low- and high-ends). That's kind of a special case though. |
|
Yes, improved defaults are definitely needed, not only for the colour scheme but also for text sizes, line widths, etc. I will merge this PR now and open a new issue (and ~immediately start working on that) for those - I believe that is a separate concern, also across both plotly and the ggplot2 backends. |



Hopefully fixes #30 - could you take a look?