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绘 ...
随机推荐
- [软工作业]-软件案例分析-CSDN
[软工作业]-软件案例分析-CSDN(app) 项目 内容 这个作业属于哪个课程 2020春季计算机学院软件工程(罗杰 任健) 这个作业的要求在哪里 个人博客作业-软件案例分析 我在这个课程的目标是 ...
- WEB前端工程师如何做职业规划?
对于一个WEB前端的职业规划,其实是有各种的答案,没有哪种答案是完全正确的,全凭自己的选择,只要是自己选定了,坚持去认真走,就好.在这里, 我只是 简要说一下自己对于这块儿内容的理解.有一个观点想要分 ...
- RabbitMQ的一些理解和笔记
在这篇博客中,简单记录一下 rabbitmq 服务器中一些基本的概念. Connection: connection 为 TCP连接,是我们的应用程序和RabbitMQ服务器真正发送和接收数据的地方. ...
- OSI参考模型(应用层、表示层、会话层、传输层、网络层、数据链路层、物理层)
文章转自:https://blog.csdn.net/weixin_43914604/article/details/104589085 学习课程:<2019王道考研计算机网络> 学习目的 ...
- 使用vsftpd 搭建ftp服务
ftp 基础服务器基础知识 ftp有三种登录方式.匿名登录(所有用户).本地用户.虚拟用户(guest). FTP工作模式 主动模式:服务端从20端口主动向客户端发起链接. 控制端口21:数据传输端口 ...
- echarts 让轴自适应数据为小数整数
echarts 让轴自适应数据为小数整数,以解决y轴数值重复的问题 工作中突然遇到这个问题 试了一下用formatter自适应 ok 在yAxis中提阿尼按键属性 axisLabel 1 axis ...
- JavaJDK下载及配置环境变量
卸载jdk 找到原先安装jdk的位置,直接删除这个文件夹,你们叫什么名字就删哪个,我的叫javajdk. 找到我的电脑,右键属性,然后找到环境变量. 删除系统变量里面的JAVA_HOME变量 再双击击 ...
- wm_concat结果长度限制的有关问题 ORA-06502: PL/SQL: 数字或值错误
该函数作用是把列值合并(用英文逗号分割),但是数量有限制,返回的字符数上线是4000(oracle11g),超过会报错,听说oracle版本到 11.2.0.2.0 或以上返回的是clob类型,长度就 ...
- Part 15 AngularJS ng init directive
The ng-init directive allows you to evaluate an expression in the current scope. In the following e ...
- [第三章]c++学习笔记2(静态成员变量)
静态成员:在说明前加了static关键字的对象 使用例: 基本概念 普通成员变量每个对象有各自的一份,而静态成员变量总共只有一份,为所有对象共享. 普通成员函数必须具体作用与某个对象,而静态成员函数并 ...