r语言ggplot更改主题
目录
ggplot自带的主题
下面是ggplot2里自带的主题
ggthemes里的主题
install.packages("ggthemes")
library(ggthemes)
ggthems
当你打开这个链接你会发现:
这里图片的演示都看不到,所以我就一个一个的试给大家看
这是我使用的数据框,非常简单
x<-c(1:5)
y<-x^2
xy<-data.frame(x,y);xy
1.theme_few
ggplot(xy,aes(x,y))+geom_point()+geom_smooth(aes(y~x))+
theme_few()
原来的网格消失了
2.theme_clcs
ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+theme_calc()
增加了线条
3.theme_economist
这里有两个,区别就是颜色不同
ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+theme_economist_white()
ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+theme_economist()
4.theme_excel
同样有两个
ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+theme_excel()
ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+theme_excel_new()
5.`theme_fivethirtyeight
ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+
theme_fivethirtyeight()
6. theme_gdocs
ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+
theme_gdocs()
7. theme_get
呃呃,这个是ggplot2自带的主题
ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+
theme_get()
8.theme_hc
ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+
theme_hc()
9.theme_igray
给线换个颜色吧
ggplot(xy,aes(x,y))+geom_point(shape=17,size=9)+stat_smooth(color=3)+
theme_igray()
10 theme_map
ggplot(xy,aes(x,y))+geom_point(shape=17,size=9)+stat_smooth(color=3)+
theme_map()
11.theme_pander
ggplot(xy,aes(x,y))+geom_point(shape=17,size=9)+stat_smooth(color=3)+
theme_pander()
12.theme_par
ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
theme_par()
13.theme_solarized
这个也有两个
ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
theme_solarized()
ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
theme_solarized_2()
14.theme_solid
ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
theme_solid()
15.theme_stata
ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
theme_stata()
16.theme_tufte
ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
theme_tufte()
17. theme_wsj
ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
theme_wsj()