今天来总结一下ggplot2中的图片底色设置。
底色有很多种,使用以下命令来设定:
theme_bw() #white background and gray grid lines
theme_light() #light gray lines and axis (more attention towards the data)
theme_test() #Only axis and black lines around the plot
theme_dark() #Dark background designed to make colours pop out
theme_get() #就是默认那个
theme_classic()
theme_linedraw() #black lines around the plot
theme_minimal() #no background annotations
theme_grey()
theme_gray()
theme_replace()
下面我们来看一下不同的效果
theme_bw()和theme_light()效果差不多
theme_light(),比bw的边框浅色一点 theme_test()
theme_get(),其实就是我们平时默认的那个
theme_classic()
theme_dark()
theme_gray(),跟theme_grey(),theme_replace()和theme_get()差不多
theme_linedraw()
theme_minimal
所有以上这些theme_xx()均可以使用两个参数
base_size() #base font size (to change the size of all plot text elements)
base_family() #base font family
附上violin图代码
setwd("G:/工作/分析/26. 新自残转录组-48样本(30自残+18僵虫)/分析/02. 基因表达")
library(ggplot2)
a = read.table("FPKM-Har.txt",header = T)
fa = ggplot(a,aes(x=Groups,y=FPKM,fill=Groups))+
geom_violin(width=0.8)+
geom_boxplot(width=0.1,fill="white")+
ggtitle("Expression in different groups")+
ylab("Log2(FPKM+0.001")+
theme_test()+
theme(plot.title = element_text(face = "bold",size = 16),
axis.title.x = element_text(face = "bold",size = 14),
axis.title.y = element_text(face = "bold",size = 14),
legend.title = element_text(face = "bold",size = 14),
axis.text.x = element_text(size = 12,colour = "red",angle = 45,hjust = 1,vjust = 1),
axis.text.y = element_text(size = 12),
legend.text = element_text(size = 12))
fa
网友评论