Themes#258
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
I've just pushed what should hopefully be a simpler (safer?) workaround for setting and reverting themes. The basic idea is that tinytheme("dark")
plt(1:10)
tinytheme()
par(las = 1)
plt(0:10)and the second plot will have horizontal axis labels even though they were specified at load time. I've tested with Quarto and everything seems to be working as expected there too. Feel free to kick the tyres yourself.
Not yet, but I'll take a crack at that next; hopefully tomorrow. |
|
P.S.
This is super pedantic since most users would just call |
|
I don't have very strong opinions on this - but I also don't fully get what you are proposing. Do you want to get rid of My feeling is still that having an explicit But maybe I'm also missing the details of the new logic of the implementation...I haven't been following this thread very carefully. By calling |
|
Tried it on my computer, and things look great. Thanks for the better solution! Looks like you reverted to boldface for the titles. I feel pretty strongly that all our themes except I also kind of agree with Achim that "default" is more natural, despite the slight complications in implementation that you note. But I don't feel as strongly about that one. |
- Also tidy up
|
Update: Dynamic margin adjustment is turning out to be a lot harder than expected. Every time I fix one issue, two more appear. Ironically, one of the main sticking points is our new hook mechanism, which conflicts with some of the just-in-time adjustments that we need to make after measuring label widths etc. :-/ I'm still hoping to plug the remaining gaps, but will probably take a few days at least. |
|
Okay, another update. I think I've got dynamic margin adjustment mostly working. Still a few rough edges, but quick demo below. First, a basic plot for comparison: tinyplot(
Sepal.Length ~ Petal.Length | Species, data = iris,
main = "Dynamic plot adjustment and whitespace reduction",
sub = "For themes with las = 1, etc."
)Next, a basic tinytheme("dark")
tinyplot(
Sepal.Length ~ Petal.Length | Species, data = iris,
main = "Dynamic plot adjustment and whitespace reduction",
sub = "For themes with las = 1, etc."
)Next, a fancier version with a legend but—more importantly—long y-axis labels. Note the left-hand plot margin adjusts to make space for this longer text. tinyplot(
I(Sepal.Length*1e9) ~ Petal.Length | Species, data = iris,
main = "Dynamic plot adjustment and whitespace reduction",
sub = "For themes with las = 1, etc."
)Two more examples, just demonstrating that dynamic adjustment also carries over to faceted plots. tinytheme("clean")
tinyplot(
I(mpg*1e3) ~ hp | disp, data = mtcars, facet = cyl ~ am,
main = "Dynamic plot adjustment and whitespace reduction",
sub = "Works with facets too"
)tinytheme("dark")
tinyplot(
I(mpg*1e3) ~ hp | disp, data = mtcars, facet = cyl ~ am,
main = "Dynamic plot adjustment and whitespace reduction",
sub = "Works with facets too"
)# reset theme
tinytheme() |
|
Wow! This looks amazing!!! Out of curiosity, does the auto margin parameter in tpar() override all user supplied settings, or is it still possible for them to change? For example, if I think that main and sub are too tight with one a other, can I add some spacing? |
|
Either way, I think this PR is getting massive, and that we should think about merging soon. Then, we can iterate to improve the themes and add flexibility where needed. |
Yes and no. It's a bit complicated, but I'll try to explain briefly: I ended up deciding to narrowly interpret "dynamic" as limited to To that end, the whitespace reduction specifically around the axis titles etc. is actually baked into the theme default Okay, now to your question. Here's a default plot for the tinytheme("bw")
tinyplot(
I(Sepal.Length*1e9) ~ Petal.Length, data = iris,
main = "Title of the plot",
sub = "Subtitle of the plot"
)This theme includes an extra 0.5 line whitespace penalty around the margin of the axis titles (and a similar adjustments for shorter tick lines, but we can ignore that for this example). To undo this whitespace reduction, we could do: # remove (undo?) extra 0.5 whitespace reduction around axis titles
tinytheme("bw",
mar = c(5.1, 4.1, 4.1, 2.1) - c(1+0.3, 0.3, 0, 1.5),
mgp = c(3, 1, 0) - c(0.3, 0.3, 0))
tinyplot(
I(Sepal.Length*1e9) ~ Petal.Length, data = iris,
main = "Title of the plot",
sub = "Subtitle of the plot"
)(Note the axis titles have more space around them.)
This, unfortunately we can't change right now since (Another option would be to include a linebreak in either |
Agree! I need to jump to some work stuff now, but will make a list of STILL TODO items this and then we can decide what squeeze in now versus address in a later PR. |
|
Fixed a few more issues, added tests, and updated the docs. I think that this is in pretty good shape now. Still some rough edges here or there (e.g., themes don't play nicely with |
Yay! I think the next release is going to be a game changer |
|
+1 The updates are massive and it's very impressive what you have put together with the types and themes. |







(Includes GM edits)
Closes #234
Closes #112
Out of scope or not PR-specific. Should be a separate issue:
ylaband axis automatically. This is important when axis labels are horizontal, as is default in many themes. Default axis spacing parameters #112 Update: addressed by 9d1380b