我在绘制GSEA图的时候,想将图片保存PDF,代码如下:
p <- gseaplot2(gsea_res, geneSetID = 1:5)
p[[1]] <- p[[1]] + scale_color_viridis_d(labels = c("TNFA_SIGNALING_VIA_NFKB","EPITHELIAL_MESENCHYMAL_TRANSITION","PROTEIN_SECRETION","APOPTOSIS","IL2_STAT5_SIGNALING"))+
geom_hline(yintercept = 0,color = "grey75", linewidth = 0.8, linetype = 2)+
theme(legend.position = "top", legend.direction = "horizontal")
p[[2]] <- p[[2]] + scale_color_viridis_d()
p[[3]] <- p[[3]] + geom_hline(yintercept = 0, color = "steelblue", linewidth = 0.5, linetype = 2)
p
pdf("gseaplot_M.pdf",width=15,height=5)
print(p)
dev.off()
将width设置10的时候图片被拉长,图例显示不完全
将width设置15的时候图片被拉长,这个时候图例可以显示完全
如何可以保持图片正常比例,调整保存图片的边距
