ggplot(plotdata,aes(x=RDA1,y=RDA2,color=plotdata$Group))+ #geom_point(size=4,aes(color = plotdata$Group,shape=plotdata$Treatment))+ # #guides(color=guide_legend(title = "Bac"),shape=guide_legend(title = ""))+ #改图例名称 #stat_ellipse(geom = "polygon",linewidth=0.5,level = 0.95,alpha = 0.1)+ #圈 geom_segment(data=RDAE,aes(x = 0, y = 0, xend = RDAE[,1]*3.5, yend = RDAE[,2]*3.5), arrow = arrow(length = unit(0.03, 'npc')),linewidth =0.4,color="gray2",size = 3)+ #箭头 geom_text(data = RDAE,aes(RDA1 * 3.9,RDA2 * 3.6,label = rownames(RDAE)),color = 'gray2',size = 4)+ xlab(paste("RDA1 (",rda1,"%",")"))+ylab(paste("RDA2 (",rda2,"%",")"))+ theme_bw(base_line_size = 1.05,base_rect_size = 1.05)+ scale_color_manual(values=c("#3FBDA7","#0172B6","#BD3C29","#F0965D","#BEBADA"))+ scale_shape_manual(values = c(1,2,3))+ theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank(), legend.position = c(0.97, 0.85), #修改图例位置 legend.background = element_blank(), # 设置图例背景为透明 )+ geom_hline(aes(yintercept=0), colour="gray45",size=0.5, linetype="dashed")+ geom_vline(aes(xintercept=0), colour="gray45",size=0.5, linetype="dashed")+ labs(title = "Bac")+ theme(plot.title = element_text(#family = "serif"字体 size = 20, #字体大小 hjust = 0.5, #字体左右的位置 vjust = 0.5, #字体上下的高度 angle = 0, #字体倾斜的角度 )) 请设置xlab和ylab的字体大小
时间: 2023-12-14 16:02:19 浏览: 125
好的,你可以使用 `theme()` 函数来设置 `xlab` 和 `ylab` 的字体大小。示例代码如下:
```
ggplot(plotdata, aes(x = RDA1, y = RDA2, color = Group)) +
geom_point(size = 4, aes(shape = Treatment)) +
geom_segment(data = RDAE, aes(x = 0, y = 0, xend = RDAE[,1] * 3.5, yend = RDAE[,2] * 3.5),
arrow = arrow(length = unit(0.03, 'npc')), linewidth = 0.4, color = "gray2", size = 3) +
geom_text(data = RDAE, aes(RDA1 * 3.9, RDA2 * 3.6, label = rownames(RDAE)), color = 'gray2', size = 4) +
xlab(paste("RDA1 (", rda1, "%", ")")) +
ylab(paste("RDA2 (", rda2, "%", ")")) +
theme_bw(base_line_size = 1.05, base_rect_size = 1.05) +
scale_color_manual(values = c("#3FBDA7", "#0172B6", "#BD3C29", "#F0965D", "#BEBADA")) +
scale_shape_manual(values = c(1, 2, 3)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
legend.position = c(0.97, 0.85), legend.background = element_blank(),
axis.title.x = element_text(size = 16), # 设置x轴标签字体大小为16
axis.title.y = element_text(size = 16)) + # 设置y轴标签字体大小为16
geom_hline(aes(yintercept = 0), colour = "gray45", size = 0.5, linetype = "dashed") +
geom_vline(aes(xintercept = 0), colour = "gray45", size = 0.5, linetype = "dashed") +
labs(title = "Bac") +
theme(plot.title = element_text(size = 20, hjust = 0.5, vjust = 0.5, angle = 0))
```
在此示例代码中,我设置了 `axis.title.x` 和 `axis.title.y` 来分别设置 `xlab` 和 `ylab` 的字体大小为 16。你可以根据需要调整字体大小。
阅读全文