R语言ggplot2更改主题

r语言ggplot更改主题

目录

r语言ggplot更改主题

ggplot自带的主题

ggthemes里的主题

1.theme_few

2.theme_clcs

3.theme_economist

4.theme_excel

5.`theme_fivethirtyeight

6. theme_gdocs

7. theme_get

8.theme_hc

9.theme_igray

10 theme_map

11.theme_pander

12.theme_par

13.theme_solarized

14.theme_solid

15.theme_stata

16.theme_tufte

17. theme_wsj


ggplot自带的主题

下面是ggplot2里自带的主题
cb665d36d6dc494cb624acda6589fece.png

ggthemes里的主题

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

ggthems
当你打开这个链接你会发现:
0c3758e539cc4d3b84dd82c9d0983786.png
这里图片的演示都看不到,所以我就一个一个的试给大家看
这是我使用的数据框,非常简单

x<-c(1:5)
y<-x^2
xy<-data.frame(x,y);xy

b61a959781fc431b8f55939495b15afc.png

1.theme_few

ggplot(xy,aes(x,y))+geom_point()+geom_smooth(aes(y~x))+
             theme_few()

原来的网格消失了
f8edf434bab041deb754282c48ef8296.png

2.theme_clcs

ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+theme_calc()

增加了线条
3b07861a7c0947bf80c6cae800a615ec.png

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()

c675832c5da0492b94a469d2d5672020.png

8256bea5ad2149d8a156eb86da78fa93.png

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()

d81b617653194408bca82d7d144ae971.png
2855aa0061ad46ebb8d701e4fc36896a.png

5.`theme_fivethirtyeight

ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+
  theme_fivethirtyeight()

7c86ca49e499442ba8970fc57fc81a2a.png

6. theme_gdocs

ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+
  theme_gdocs()

862f77371de64f5392074a2067a3aa68.png

7. theme_get

呃呃,这个是ggplot2自带的主题

ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+
  theme_get()

833a8af643ce47c78ac531b3ab3e19f0.png

8.theme_hc

ggplot(xy,aes(x,y))+geom_point()+stat_smooth()+
  theme_hc()

9fe2006910764c56b7aeb21b47078ae8.png

9.theme_igray

给线换个颜色吧

ggplot(xy,aes(x,y))+geom_point(shape=17,size=9)+stat_smooth(color=3)+
  theme_igray()

258e1341ac894894ac71eac143f2704d.png

10 theme_map

 ggplot(xy,aes(x,y))+geom_point(shape=17,size=9)+stat_smooth(color=3)+
  theme_map()

99c257b3144443d2aaa5b53bbbd35b14.png

11.theme_pander

ggplot(xy,aes(x,y))+geom_point(shape=17,size=9)+stat_smooth(color=3)+
  theme_pander()

e500f98502b04c2a8468ec75ce505e47.png

12.theme_par

ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
  theme_par()

454603250ef24665aeb02a4dcd3fc24c.png

13.theme_solarized

这个也有两个

ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
  theme_solarized()

a8fa3b8c61c54511ac97499ea1120cf6.png

ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
  theme_solarized_2()

cc1b791f4c314da69653cad24f380ecc.png

14.theme_solid

ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
  theme_solid()

3727b46ec8f84e7fbb216eba81adc9ee.png

15.theme_stata

ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
  theme_stata()

5ec71234347a4174b5d74845475826e9.png

16.theme_tufte

ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
  theme_tufte()

51008949d05249e4b33f233d619630fc.png

17. theme_wsj

ggplot(xy,aes(x,y))+geom_point(shape=17,size=5)+stat_smooth(color=3)+
  theme_wsj()

a10d005d9752470287e1e0f4328843fd.png

  • 6
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值