作图rna_seq

R语言:ggplot主题包ggthemes

2020-09-23  本文已影响0人  胡童远

导读

看看ggthemes有哪些花样。

参考:ggthemes: Extra Themes, Scales and Geoms for 'ggplot2'

输入数据

install.packages("ggthemes")
library("ggthemes")
library("ggplot2")

value = sample(c(1:10), 10, replace=T)
group = paste("Sample", sample(c(1:2), 10, replace=T), sep="_")
df = data.frame(value, group)

默认背景画图

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value")

常用背景1:theme_bw

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_bw()

常用背景2:theme_classic

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_classic()

ggthemes的那些主题(一到十八)

一、主题:theme_calc

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_calc()

二、经济学人主题:theme_economist

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_economist()

三、主题:theme_igray

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_igray()
图片.png

四、主题:theme_fivethirtyeight

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_fivethirtyeight()

五、主题:theme_pander

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_pander()

六、主题:theme_foundation

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_foundation()

七、主题:theme_base

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_base()

八、主题:theme_par

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_par()

九、主题:theme_gdocs

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_gdocs()

十、主题:theme_map

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_map()

十一、主题:theme_few

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_few()

十二、主题:theme_tufte

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_tufte()

十三、主题:theme_stata

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_stata()

十四、主题:theme_excel

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_excel()

十五、华尔街日报主题:theme_wsj

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_wsj()

十六、主题:theme_hc

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_hc()

十七、主题:theme_solid

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_solid()

十八、主题:theme_solarized

ggplot(df, aes(x = factor(rownames(df), levels=rownames(df)), y = value, fill = group, color = group)) +
  geom_point(pch=21) +
  geom_line(group=group) +
  labs(x="", y="value") +
  theme_solarized()
上一篇下一篇

猜你喜欢

热点阅读