2022-06-29_R:ggthemr包修改ggplot主题&

2022-06-30  本文已影响0人  jiarf

大家都知道ggplot可以作图画主题,但是什么样的主题我们可以选择呢,这里记录一下今天新找到的一个包来更改ggplot的主题

## ggthemr包选择一个主题,主要是方便,也可以手动修改颜色
ggthemr('greyscale') #在这里直接加载这个主题后,后面会自动用这个主题
接下来是画图的部分
p1<-ggplot(data2, aes(x=cell.type, y=percent, fill=group)) +
  geom_bar(stat="identity",position=position_dodge(0.7),width = .6)+ 
  theme_bw()
p1
ggthemr('dust') 
p1
ggthemr('grape')
p1
ggthemr('light')
p1
ggthemr('flat')
p1
ggthemr('flat-dark')
p1
ggthemr('camouflage')
p1
ggthemr('chalk')
p1
> ggthemr('copper')
> p1
> ggthemr('earth')
> p1
> ggthemr('fresh')
> p1
> ggthemr('grass')
> p1
> ggthemr('greyscale')
> p1
> ggthemr('lilac')
> p1
> ggthemr('pale')
> p1  
> ggthemr('sea')
> p1
> ggthemr('sky')
> p1
> ggthemr('solarized')
> p1
ggthemr_reset()
p1

这样就可以恢复默认的ggplot的主题


ggplot主题

theme_gray() – signature ggplot2 theme
theme_bw() – dark on light ggplot2 theme
theme_linedraw() – uses black lines on white backgrounds only
theme_light() – similar to linedraw() but with grey lines aswell
theme_dark() – lines on a dark background instead of light
theme_minimal() – no background annotations, minimal feel.
theme_classic() – theme with no grid lines.
theme_void() – empty theme with no elements
上一篇下一篇

猜你喜欢

热点阅读