Mikata-Project / ggthemr

Themes for ggplot2.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot change swatch colors using ggthemr()

orbitoo opened this issue · comments

Each time I use "ggthemr" to change my theme, I have to change the colors manually. It seems that function ggthemr() does nothing to colors.
Here are my codes as an example.

library(ggplot2)
library(ggthemr)
ggthemr("chalk", "scientific")
ggplot(mpg, aes(displ, hwy, color = factor(cyl), shape = factor(cyl))) +
    geom_jitter() +
    geom_smooth(method = lm, formula = y ~ poly(x, 2)) +
    labs(shape = "cyl", color = "cyl")

Generates:
Example1@4x

library(ggplot2)
library(ggthemr)
ggthemr("chalk", "scientific")
defaultColor <- swatch()[seq_len(swatch())]
ggplot(mpg, aes(displ, hwy, color = factor(cyl), shape = factor(cyl))) +
    scale_color_manual(values = defaultColor[2:5]) +
    geom_jitter() +
    geom_smooth(method = lm, formula = y ~ poly(x, 2)) +
    labs(shape = "cyl", color = "cyl")

Generates:
Example2@4x