1、theme_gray() p1<-p+theme_gray()+ggtitle("theme_gray()")+ theme(legend.position = 'none') p1 2、theme_bw() p2<-p+theme_bw()+ggtitle("theme_bw()")+ theme(legend.position = 'none') p2 3、theme_classic() p3<-p+theme_classic()+ggtitle("theme_classic()")+ theme(legend.po...
plot<-ggplot(data=NULL,aes(x=NULL,y=boxplot_data))+geom_boxplot()+theme_classic()print(plot) 1. 2. 3. 4. 5. 代码解释: plot <- ggplot(data = NULL, aes(x = NULL, y = boxplot_data)) + ...:将绘图对象赋值给变量plot。 print(plot):打印并显示绘图结果。 完整代码 下面是完整的...
p1<-p+theme_gray()+ggtitle("theme_gray()")+theme(legend.position='none')p1 2、theme_bw() p2<-p+theme_bw()+ggtitle("theme_bw()")+theme(legend.position='none')p2 3、theme_classic() p3<-p+theme_classic()+ggtitle("theme_classic()")+theme(legend.position='none')p3 4、theme_ligh...
Step 6: 绘制OTU物种丰度堆叠柱状图 ggplot(dat, aes(sample, value, fill = OTU)) + geom_bar(stat="identity", position = 'fill')+ xlab("") + ylab("") + theme_classic(base_size = 7) + scale_y_continuous(expand = c(0,0)) + ggtitle('OTU') + guides(fill=guide_legend(title=NULL...
p <- ggplot(data=mpg,mapping=aes(x=class,y=hwy))+ stat_boxplot(geom = "errorbar",width=0.15,mapping=aes(color=class))+ geom_boxplot(mapping=aes(color=class),width=0.3,position = "dodge2")+ theme_classic()+ theme(axis.ticks.x=element_blank())+ ...
ggplot2默认主题 1、theme_gray() p1<-p+theme_gray()+ggtitle("theme_gray()")+theme(legend.position='none')p1 image.png 2、theme_bw() p2<-p+theme_bw()+ggtitle("theme_bw()")+theme(legend.position='none')p2 image.png 3、theme_classic() ...
theme_classic(): 只有x、y轴没有背景和网格线 theme_void(): 完全空白的主题 创建一个简单的数据集作为例子,分别设置成以上七个主题: df <- data.frame(x = 1:3, y = 1:3) base <- ggplot(df, aes(x, y)) + geom_point() base + theme_grey() + ggtitle("theme_grey()") ...
酷炫系列 ggthemes包ggthemes 样图三两张: ggplot2 常用系列 theme_gray() # the default theme_bw() theme_linedraw() theme_light() theme_dark() theme_minimal() theme_classic() #推荐学术绘图 theme_void() !!! Reference link:Ref __EOF__...
`theme_classic()`则提供了一种更传统、稍显丰富的外观,适合作为默认主题使用。示例 以下是一个使用`theme_bw()`创建基本图表的示例:r library(ggplot2)示例数据 df <- data.frame(x = 1:10, y = c(2, 4, 6, 8, 10, 12, 14, 16, 18, 20))创建图表并使用内置主题 ggplot(df, ...
library(ggplot2) #使用数据集mtcars演示 ggplot(mtcars)+geom_point(aes(wt, mpg), color="red")+ geom_text(aes(wt, mpg, label=rownames(mtcars)))+ theme_classic(base_size = 16) 可以看到可视化效果不是很好。接下来看看包ggrepel的效果。