一般情况下只会设置palette 参数,指定主题名称,其它均为默认参数【即每种主题的字号,磅值,图边距等均可修改】。
library(ggthemr)
options(repr.plot.width = 4.5, repr.plot.height = 3, repr.plot.res = 300)
ggthemr('grape')
ggplot(mpg, aes(manufacturer, hwy)) +
geom_boxplot() +
ggtitle('flat')+
theme(axis.text.x = element_text(angle = 45))
ggthemr_reset()
ggplot(mpg, aes(manufacturer, hwy)) +
geom_boxplot() +
theme(axis.text.x = element_text(angle = 45))
ggplot(mtcars, aes(mpg, disp, colour = factor(am))) +
geom_point() +
scale_colour_ggthemr_d()
flat
Base 16
Base 16
2 ggsci
install.packages("ggsci")
vignette("ggsci") # in R for a quick-start guide.
library("ggsci")
library("ggplot2")
library("gridExtra")
data("diamonds")
p1 = ggplot(subset(diamonds, carat >= 2.2),
aes(x = table, y = price, colour = cut)) +
geom_point(alpha = 0.7) +
geom_smooth(method = "loess", alpha = 0.05, size = 1, span = 1) +
theme_bw()
p2 = ggplot(subset(diamonds, carat > 2.2 & depth > 55 & depth < 70),
aes(x = depth, fill = cut)) +
geom_histogram(colour = "black", binwidth = 1, position = "dodge") +
theme_bw()
2.1 NPG
p1_npg = p1 + scale_color_npg() + ggtitle("scale_color_npg()")
p2_npg = p2 + scale_fill_npg() + ggtitle("scale_fill_npg()")
grid.arrange(p1_npg, p2_npg, ncol = 2)
2.2 AAAS
p1_aaas = p1 + scale_color_aaas() + ggtitle("scale_color_aaas()")
p2_aaas = p2 + scale_fill_aaas() + ggtitle("scale_fill_aaas()")
grid.arrange(p1_aaas, p2_aaas, ncol = 2)
更多图片示例,请查看
vignette("ggsci") # in R for a quick-start guide.
#scale_fill_westeros
ggplot(mpg, aes(displ)) +
geom_histogram(aes(fill = class), col = "black", size = 0.1) +
scale_fill_westeros(palette = "Stannis", n = 7, reverse = TRUE) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
labs(title = glue("
We do not choose our destinies.
Yet we must... we must do our duty, no?
Great or small, we must do our duty."),
subtitle = "I will have no burnings. Pray Harder.",
caption = glue("
The Iron Throne is Mine by Right.
- Stannis Baratheon"),
x = "Bent Knees", y = "Lightbringer") +
theme_minimal() +
theme(text = element_text(family = "Cinzel", size = 20),
plot.title = element_text(family = "Cinzel", size = 26),
plot.subtitle = element_text(size = 18),
plot.caption = element_text(size = 16),
axis.text = element_text(size = 18),
legend.position = "none")