R语言与医学统计图形-【26】ggplot2主题函数
ggplot2绘图系统——主题函数
1. theme函数
theme_*系列函数提供了9种不同的风格。
theme_grey/gray/bw/linedraw/light/minimal/classic/dark/void都只有2个参数:base_size表示文字大小,base_family表示字体。
mg <- ggplot(mtcars,aes(x=mpg,y=wt))+geom_point()
a=mg+theme_bw()+geom_text(aes(x=25,y=5),label='theme_bw',color='red',size=10)
b=mg+theme_classic()+geom_text(aes(x=25,y=5),label='theme_classic',color='red',size=10)
c=mg+theme_dark()+geom_text(aes(x=25,y=5),label='theme_dark',color='red',size=10)
d=mg+theme_light()+geom_text(aes(x=25,y=5),label='theme_light',color='red',size=10)
e=mg+theme_get()+geom_text(aes(x=25,y=5),label='theme_get',color='red',size=10)
f=mg+theme_linedraw()+geom_text(aes(x=25,y=5),label='theme_linedraw',color='red',size=10)
g=mg+theme_replace()+geom_text(aes(x=25,y=5),label='theme_replace',color='red',size=10)
h=mg+theme_minimal()+geom_text(aes(x=25,y=5),label='theme_minimal',color='red',size=10)
i=mg+theme_void()+geom_text(aes(x=25,y=5),label='theme_void',color='red',size=10)
grid.arrange(a,b,c,d,e,f,g,h,i,ncol=3)

2. ggthemes包
ggplot2扩展包,包括主题函数和标度函数。
ggthemes包种最常见的12种主题。
p <- ggplot(mtcars,aes(x=wt,y=mpg,color=factor(gear)))+
geom_point()+labs(title = 'Cars')+
theme(plot.title = element_text(hjust = 0.5,family = 'Times New Roman'))
a <- p+theme_economist()+scale_color_economist()+
geom_text(aes(x=4,y=30),label='theme_economist',color='deeppink')
b <- p+theme_solarized()+scale_color_solarized('blue')+
geom_text(aes(x=4,y=30),label='theme_solarized',color='deeppink')
c <- p+theme_solarized(light = FALSE)+scale_color_solarized('red')+
geom_text(aes(x=4,y=30),label='theme_dark',color='deeppink')
d <- p+theme_solarized(light = FALSE)+scale_color_solarized('blue')+
geom_text(aes(x=4,y=30),label='theme_dark2',color='deeppink')
grid.arrange(a,b,c,d,ncol=2)

e <- p+theme_stata()+scale_color_stata()+geom_text(aes(x=4,y=30),label='theme_stata',color='deeppink')
f <- p+theme_igray()+geom_text(aes(x=4,y=30),label='theme_igray',color='deeppink')
g <- p+theme_igray()+scale_color_tableau()+geom_text(aes(x=4,y=30),label='theme_igray',color='deeppink')
h <- p+theme_wsj()+scale_color_wsj('colors6','')+geom_text(aes(x=4,y=30),label='theme_wsj',color='deeppink')
grid.arrange(e,f,g,h,ncol=2)

i <- p+theme_calc()+scale_color_calc()+geom_text(aes(x=4,y=30),label='theme_calc',color='deeppink')
j <- p+theme_pander()+scale_color_pander()+geom_text(aes(x=4,y=30),label='theme_pander',color='deeppink')
k <- p+theme_hc()+scale_color_hc()+geom_text(aes(x=4,y=30),label='theme_hc',color='deeppink')
l <- p+theme_hc(bgcolor = 'darkunica')+scale_color_hc('darkunica')+geom_text(aes(x=4,y=30),label='theme_hc2',color='deeppink')
grid.arrange(i,j,k,l,ncol=2)

除了ggthemes包,还有artyfarty和ggthemr包也可设置主题,或者自定义主题函数。
R语言与医学统计图形-【26】ggplot2主题函数的更多相关文章
- R语言与医学统计图形-【28】ggplot2扩展包ggrepel、ggsci、gganimate、ggpubr
ggplot2绘图系统--扩展包ggrepel.ggsci.gganimate.ggpubr等 部分扩展包可在CRAN直接下载,有些需借助devtools包从Github下载. 1. ggrepel包 ...
- R语言与医学统计图形-【19】ggplot2坐标轴调节
ggplot2绘图系统--坐标轴调节 scale函数:图形遥控器.坐标轴标度函数: scale_x_continous scale_y_continous scale_x_discrete scale ...
- R语言与医学统计图形【1】par函数
张铁军,陈兴栋等 著 R语言基础绘图系统 基础绘图包之高级绘图函数--par函数 基础绘图包并非指单独某个包,而是由几个R包联合起来的一个联盟,比如graphics.grDevices等. 掌握par ...
- R语言与医学统计图形【5】饼图、条件图
R语言基础绘图系统 基础图形--饼图.克利夫兰点图.条件图 6.饼图 pie(rep(1,26),col=rainbow(26), labels = LETTERS[1:26], #标签 radius ...
- R语言与医学统计图形【8】颜色的选取
R语言基础绘图系统 基础绘图包之低级绘图函数--内置颜色. 1.内置颜色选取 功能657种内置颜色.colors() 调色板函数:palette(), rgb(), rainbow(). palett ...
- R语言与医学统计图形【6】低级绘图函数
R语言基础绘图系统 基础绘图包之低级绘图函数--定义坐标轴.图例.文本 低级绘图函数:本身不具备图形绘制能力,只是在已有图形基础上添加元素. 函数 功能 arrows 添加箭头 axis 坐标轴 bo ...
- R语言与医学统计图形【4】直方图、金字塔图
R语言基础绘图系统 基础图形--直方图.金字塔图 3.直方图 参数设置及比较. op <- par(mfrow=c(2,3)) data <- rnorm(100,10,5) hist(d ...
- R语言与医学统计图形【3】条形图、误差图
R语言基础绘图系统 基础图形--条形图.误差图 3.条形图 barplot接收的数据是矩阵而非数据框. data <- sample(c(50:80),5) barplot(data,col=h ...
- R语言与医学统计图形【2】散点图、盒形图
R语言基础绘图系统 基础图形--散点图.盒形图 plot是一个泛型函数(generic method),对于不同的数据绘制不同的图形. par函数的大部分参数在plot中通用. 1.散点图 plot绘 ...
随机推荐
- 正则表达式: NFA引擎匹配原理
NFA引擎匹配原理 1 为什么要了解引擎匹配原理 一个个音符杂乱无章的组合在一起,弹奏出的或许就是噪音,同样的音符经过作曲家的手,就可以谱出非常动听的乐曲,一个演奏者同样可以照着乐谱奏出动 ...
- 【二食堂】Beta - 发布声明
Beta - 发布声明 新功能 在Beta阶段,图谱方面的新功能有:自定义关系的添加与删除.实体查找.实体名称的修改.实体之间关系的修改.新增了项目创建与删除功能,此外还增加了好友系统,可以实现好友的 ...
- [HNOI2009]双递增序列(洛谷P4728)+小烈送菜(内部训练题)——奇妙的dp
博主学习本题的经过嘤嘤嘤: 7.22 : 听学长讲(一知半解)--自己推(推不出来)--网上看题解--以为自己会了(网上题解是错的)--发现错误以后又自己推(没推出来)--给学长发邮件--得到正确解法 ...
- Machine learning(2-Linear regression with one variable )
1.Model representation Our Training Set [训练集]: We will start with this ''Housing price prediction'' ...
- STL 去重 unique
一.unique函数 类属性算法unique的作用是从输入序列中"删除"所有相邻的重复元素. 该算法删除相邻的重复元素,然后重新排列输入范围内的元素,并且返回一个迭代器(容器的长度 ...
- (1)Zookeeper在linux环境中搭建集群
1.简介 ZooKeeper是Apache软件基金会的一个软件项目,它为大型分布式计算提供开源的分布式配置服务.同步服务和命名注册.ZooKeeper的架构通过冗余服务实现高可用性.Zookeeper ...
- Python学习路线【对标大厂Python工程师的招聘要求,并推荐优质免费资源】打卡学习不迷茫
您好,我是码农飞哥,感谢您阅读本文,欢迎一键三连哦. 本文要点:从Python爬虫工程师的招聘要求出发制定学习路线,同时还推荐免费优质的学习资源. 打卡学习不迷茫. 干货满满,建议收藏,需要用到时常看 ...
- SpringCloud升级之路2020.0.x版-31. FeignClient 实现断路器以及线程隔离限流的思路
本系列代码地址:https://github.com/JoJoTec/spring-cloud-parent 在前面一节,我们实现了 FeignClient 粘合 resilience4j 的 Ret ...
- java中使用Process执行linux命令
代码如下 BufferedReader reader = null; String cmd = "netstat -anp|grep :8080";//命令中有管道符 | 需要如下 ...
- 论文解读(DeepWalk)《DeepWalk: Online Learning of Social Representations》
一.基本信息 论文题目:<DeepWalk: Online Learning of Social Representations>发表时间: KDD 2014论文作者: Bryan P ...