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

Change colors without set theme #46

Open
Adrian-AlvarezMolina opened this issue Apr 8, 2021 · 1 comment
Open

Change colors without set theme #46

Adrian-AlvarezMolina opened this issue Apr 8, 2021 · 1 comment

Comments

@Adrian-AlvarezMolina
Copy link

Adrian-AlvarezMolina commented Apr 8, 2021

Hi, first of all congrats for the amazing package and themes !

Following the examples I achieve to change the theme of a ggplot2 object following your instructions in the last part

Next line set the theme

dust_theme <- ggthemr(palette = "dust", set_theme = FALSE)

Next line pass the theme object from dust_theme to example_plot, works fine for me

example_plot + dust_theme$theme

Here's come the issue, when I try to pass also the colors for the scale to the plot

example_plot + dust_theme$theme + dust_theme$scales$scale_fill_discrete()
warning: attempt to apply non-function

The colors doesn't change, and there's nothing in the object dust_theme referred to scales
dust_theme$scales = NULL
dust_themes$scales$scale_fill_discrete

Any idea about why the colors don't change??.
I achieve to change colors if I type, but they are not so well adapted to the background

example_plot + dust_theme$theme +scale_fill_manual(values = dust_theme$palette$swatch)

Thanks for your time and help!

@Matt-Int
Copy link
Contributor

Hi @Adrian-AlvarezMolina,

I have recreated your issue, and can confirm that using the approach in the README doesn't work.

I also found that using the swatch is the only way to change the colours without changing the theme:

library(ggthemr)

dust_theme <- ggthemr(palette = "dust", set_theme = FALSE)

ggplot(mtcars, aes(mpg, cyl, color = factor(am))) +
    geom_point() +
    dust_theme$theme + 
    scale_color_manual(values = dust_theme$palette$swatch)

As to why the colours do not change, it appears as if the dust_theme$scales does not exist, as per your original comment. I've tracked narrowed it down to this commit from last year, which removed the scales element from the theme structure.

I'll make a pull request to update the readme as this part is no longer accurate.

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

2 participants