theme_grey()为默认主题,theme_bw()为白色背景主题,theme_classic()为经典主题。 代码语言:javascript 复制 p+theme_bw()+labs(subtitle="Change theme_bw") ggplot2 扩展包主题 代码语言:javascript 复制 library(ggthemes)p+theme_economist()+labs(su
theme_gray(): gray background color and white grid lines theme_bw() : white background and gray grid lines p+theme_gray(base_size = 14) 1. p+theme_bw() 1. theme_linedraw : black lines around the plot theme_light : light gray lines and axis (more attention towards the data) p ...
p + theme(panel.grid.major = element_blank(), #主网格线panel.grid.minor = element_blank(), #次网格线panel.border = element_blank(), #边框axis.title = element_blank(), #轴标题axis.text = element_blank(), # 文本axis.ticks = element_blank()) +labs(title="Modified Background", subt...
ggplot(data=data,aes(x=logFC,y=-log10(adj.P.Val),color=change))+geom_point(alpha=0.8,size=1)+theme_bw(base_size=15)+theme(panel.grid.minor=element_blank(),panel.grid.major=element_blank())+geom_hline(yintercept=2,linetype=4)+geom_vline(xintercept=c(-1,1),linetype=4)+scale_...
图例是主题的一个方面,因此可以使用theme()功能进行修改。其中legend.justification参数可以将图例设置在图中,legend.position参数用来将图例设置在图表区域,其中x和y轴的位置(0,0)是在图表的左下和(1,1)是右上角。 # No legend ---p+theme(legend.position="None")+labs(subtitle="No Legend")# legend at ...
ggplot2 包中的主题(theme)函数用于定义绘图的风格,例如画布的背景。下图是一个黑白主题画布背景示例: ggplot(data = mtcars, aes(x = wt, y = mpg)) + geom_point(aes(color = am)) + stat_smooth() + theme_bw() 除了ggplot2 包自带的主题,还有一些扩展包提供了多种主题风格,例如 ggthemes 包、...
size=.3) + # Thinner lines scale_fill_hue(name="Sex of payer") + # Set legend title xlab("Time of day") + ylab("Total bill") + # Set axis labels ggtitle("Average bill for 2 people") + # Set title theme_bw() 18、完美的线性图 ...
# Setupoptions(scipen=999)library(ggplot2)data("midwest",package="ggplot2")theme_set(theme_bw())# Add plot components ---gg<-ggplot(midwest,aes(x=area,y=poptotal))+geom_point(aes(col=state,size=popdensity))+geom_smooth(method="loess",se=F)+xlim(c(0,0.1))+ylim(c(0,500000))+la...
theme:调整不与数据有关的图的元素的函数。theme函数采用了四个简单地函数来调整所有的主题特征:element_text调整字体,element_line调整主题内的所有线,element_rect调整所有的块,element_blank清空。theme(panel.grid =element_blank()) ## 删去网格线 facet :控制分组绘图的方法和排列形式 不指定数据集时,data =...
p + theme_bw() # Black and white theme p + theme_classic() # Classic theme Solution 2: Create, step-by-step, a ggplot with white background: p + theme( # Remove panel border panel.border = element_blank(), # Remove panel grid lines panel.grid.major = element_blank(), panel....