美文网首页
文本太长怎样处理?

文本太长怎样处理?

作者: 一路向前_莫问前程_前程似锦 | 来源:发表于2019-08-09 16:12 被阅读0次
转自Y叔叔

这个问题其实很简单,用stringr包的str_wrap来完成文本自动换行就行了。这里使用clusterProfilerbarplot来演示一下:

library(stringr)
library(ggplot2)
library(clusterProfiler)
data(geneList)de <- names(geneList)[1:100]
x <- enrichKEGG(de)
p <- barplot(x) 
p + scale_x_discrete(labels=function(x) str_wrap(x, width=10))

doyplot

library(stringr)
library(ggplot2)
p1 <- dotplot(ego2, showCategory=20) + ggtitle("dotplot for GO")+scale_y_discrete(labels=function(y) str_wrap(y, width=40))
p2 <- dotplot(kegg, showCategory=20) + ggtitle("dotplot for KEGG")+scale_y_discrete(labels=function(x) str_wrap(x, width=40))
pdf("combinde.pdf",width = 15,height = 9)
plot_grid(p2, p1, ncol=2)
dev.off()

相关文章

网友评论

      本文标题:文本太长怎样处理?

      本文链接:https://www.haomeiwen.com/subject/gjvcjctx.html