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
setting global theme: costs vs. benefits #117
Comments
Thanks for the comment. The bayesplot package didn't used to set the ggplot theme when it was loaded. It used to just hardcode a theme for each plot without affecting the rest of ggplot2, but that was actually changed in a recent release in order to make it easier to change the theme of bayesplot plots (#87). That is, You can see from the discussion at #87 that I was hesitant to do this because it changes the ggplot theme for all plots when bayesplot is loaded. But I was persuaded that since there's a precedent for this behavior in other plotting packages, the benefits outweighed the costs. That said, I can totally understand that for some people the costs outweigh the benefits. |
OK, thanks. I did search for a previous issue but missed that one. I also hate that cowplot changes the global theme too, as apparently do some other folks: So now I avoid loading that package if at all possible. I guess a solution is to use bayesplot:: In any case, thanks for the package! |
Yeah I'm also not a big fan of changing the theme when loading the package.
But I also don't like hardcoding the bayesplot theme for each plot. And I
clearly haven't been able to come up with a satisfactory resolution to that
conflict!
That said, when writing R scripts that should be reproducible, I think it's
good practice to explicitly set the plotting theme with theme_set after
loading packages. That does sidestep this problem as well as making it
clear to the reader what theme is being used.
Alternatively, like you suggested, bayesplot::fun should work fine.
…On Sun, Sep 24, 2017 at 11:58 AM grasshoppermouse ***@***.***> wrote:
OK, thanks. I did search for a previous issue but missed that one. I also
hate that cowplot changes the global theme too, as apparently do some other
folks:
https://stackoverflow.com/questions/41096293/cowplot-made-ggplot2-theme-disappear-how-to-see-current-ggplot2-theme-and-res
So now I avoid loading that package if at all possible. I guess a solution
is to use bayesplot::
In any case, thanks for the package!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#117 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHb4Q-ff9N-vdJQCoYIc5WiQq6rloj43ks5slnwbgaJpZM4Ph6vT>
.
|
@tjmahr What's your take on this issue?
…On Sun, Sep 24, 2017 at 12:15 PM Jonah Sol Gabry ***@***.***> wrote:
Yeah I'm also not a big fan of changing the theme when loading the
package. But I also don't like hardcoding the bayesplot theme for each
plot. And I clearly haven't been able to come up with a satisfactory
resolution to that conflict!
That said, when writing R scripts that should be reproducible, I think
it's good practice to explicitly set the plotting theme with theme_set
after loading packages. That does sidestep this problem as well as making
it clear to the reader what theme is being used.
Alternatively, like you suggested, bayesplot::fun should work fine.
On Sun, Sep 24, 2017 at 11:58 AM grasshoppermouse <
***@***.***> wrote:
> OK, thanks. I did search for a previous issue but missed that one. I also
> hate that cowplot changes the global theme too, as apparently do some other
> folks:
>
>
> https://stackoverflow.com/questions/41096293/cowplot-made-ggplot2-theme-disappear-how-to-see-current-ggplot2-theme-and-res
>
> So now I avoid loading that package if at all possible. I guess a
> solution is to use bayesplot::
>
> In any case, thanks for the package!
>
> —
> You are receiving this because you commented.
>
>
> Reply to this email directly, view it on GitHub
> <#117 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AHb4Q-ff9N-vdJQCoYIc5WiQq6rloj43ks5slnwbgaJpZM4Ph6vT>
> .
>
|
I don’t think bayesplot should change the global theme. I wish we could scope a theme to be the default for theme code in a package but there doesn’t seem to be a way to do that. I think adding a + theme_bayesplot() to every ggplot call is not too much of a burden. We could write a wrapper over ggplot() that calls ggplot() and adds the theme too.
|
Looking back at the issue by @gavinsimpson, #87... We don't want to be impolite and mess with the global settings. I went four years of using ggplot2 without ever having to use What if we do |
@tjmahr I think that is what I had suggested in #87 (although I don't follow why this is Importantly, however, (re)setting the theme should be done via standard functions, e.g. Whether you want to automatically set this depends on who you want to frustrate most; existing users who now find all their plots change if you don't automatically set the theme to the bayesplot default, or new users that never saw the hard-coded bayesplot theme and don't know why all their ggplot plots now look different. I'm happy either way. |
I am proposing that bayesplot have its own Basic idea:
This solves both issues:
|
@tjmahr Hmmm. Doesn't that make it harder to discover what's going on and how to turn it off? But intriguing suggestion; are you proposing to have all plots in bayesplot have That's certainly different and will likely satisfy everyone. Interested to see how this progresses. |
Yes, that’s another way of describing it. And I can make it discoverable by adjusting the start-up message.
I would like to others weigh in with any unforeseen problems with this idea.
|
This issue is a bit old now but I do think this is something we should revisit. Over at stan-dev/rstanarm#257 I proposed something similar to @tjmahr's proposal here. I'm still not sure what the best thing to do is, as all of the options seem to have downsides, but let's get this conversation started again so we can settle on something soon. |
Oh yes, what @tjmahr is describing is similar to what I imagined based on @jgabry's comment here stan-dev/rstanarm#258. I also shared some potential code for it there. I think it's any interesting solution and, like I mentioned over there, I think it would be easy to make it play nice with existing changes to the default theme set by a user by comparing whatever the theme is to I do, though, agree that all of these ways of dealing with it have their downsides. There's also something to be said about simply including a theme and not having it be defaulted anywhere, although it's probably late in the game for you all for something like that. Anyway, let me know if I can help. |
@malcolmbarrett If you’re interested in making a PR for this we’d be happy to have it. @tjmahr or I will definitely get to this eventually regardless, but you put a lot of work into that rstanarm PR that’s obviated by this change to bayesplot and I wanted to give you the opportunity to contribute a PR that’s likely to get merged! No worries if you don’t have the time, but if you’re up for it that would be great! |
Yes, I can give this a shot next week. The skeleton I posted looks like a good approach? I would also really like to embed a little hierarchy, e.g. if the user has set bayes_theme_set() to something other than the default, use that, then check against ggplot2::theme_get() to see if different than theme_grey(), otherwise use the default bayes theme. That way the user can just use ggplot2::theme_set() without having to think about it (or learn a new approach) but someone who is really just focused on bayesplot can specify both (or none, just using defaults) if desired |
Re bayesplot getting the theme from ggplot2: My concern here is that
library(bayesplot)
library(ggplot2)
should *not* set the theme of bayesplot to theme_grey().
I would prefer to just have a bayesplot get its own bayesplot_theme_get() and bayesplot_theme_set()
|
Yes, my thinking is that it would only change to whatevrer is in theme_get() if the user has done theme_set(), which is to say that if it's theme_grey, it would not override the bayesplot theme. |
I agree, I think having |
It took me a few minutes to discover why all the figures in our paper changed. Answer: one of the co-authors added some code that used bayesplot. It took another few minutes of googling to figure out how to fix that. Not a huge deal, but it's nice when loading and using a package that there are as few unintended side effects as possible. On the other hand, there are benefits if you are only using bayesplot and/or like the theme. For me, the (small) costs outweigh the benefits.
Thoughts on the cost/benefit tradeoff of setting the global ggplot theme?
The text was updated successfully, but these errors were encountered: