首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将打印大小调整为全显示,而不考虑y轴标签的长度

将打印大小调整为全显示,而不考虑y轴标签的长度
EN

Stack Overflow用户
提问于 2020-08-29 20:41:11
回答 2查看 34关注 0票数 0

我有下面的数据框架。正如你所看到的,在BIO variable.As中有一些非常长的名字,结果是我的绘图变得越来越小,而我需要尽可能大的显示出来。

代码语言:javascript
复制
BIO<-c('posttranslational protein folding (GO:0051084)posttranslational protein folding (GO:0051084)',"'de novo' protein folding (GO:0006458)",
       'posttranslational protein folding (GO:0051085)',"'de novo' protein folding (GO:0006451)",
       'posttranslational protein folding (GO:0051086)',"'de novo' protein folding (GO:00064582)",
       'posttranslational protein folding (GO:0051087)',"'de novo' protein folding (GO:00064583)",
       'posttranslational protein folding (GO:00510844)',"'de novo' protein folding (GO:00064588)",
       'posttranslational protein folding (GO:00510855)',"'de novo' protein folding (GO:00064511)",
       'posttranslational protein folding (GO:00510866)',"'de novo' protein folding (GO:000645822)",
       'posttranslational protein folding (GO:00510877)',"'de novo' protein folding (GO:000645833)")

FE<-c(5,10,15,20,25,35,10,15,5,10,15,20,25,35,10,15)
FDR<-c(7.67e-05,7.67e-05,7.67e-04,7.67e-03,7.67e-03,7.67e-03,7.67e-02,7.67e-02,
       6.67e-05,8.67e-05,4.67e-05,3.67e-05,3.67e-05,4.67e-05,5.67e-05,6.67e-05 )
d<-data.frame(BIO,FE,FDR)

# Libraries
library(ggplot2)
library(dplyr)


# Most basic bubble plot
d %>%
  arrange(desc(FDR)) %>%
  ggplot(aes(x=FE, y=BIO, size=FE, color=FDR)) +
  geom_point(alpha=0.5) +
  scale_size(range = c(.1, 24), name="Population (M)")

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-08-29 20:45:57

我建议使用scale_x_continuous()来处理x轴的比例限制。下面是示例:

代码语言:javascript
复制
BIO<-c('posttranslational protein folding (GO:0051084)posttranslational protein folding (GO:0051084)',"'de novo' protein folding (GO:0006458)",
       'posttranslational protein folding (GO:0051085)',"'de novo' protein folding (GO:0006451)",
       'posttranslational protein folding (GO:0051086)',"'de novo' protein folding (GO:00064582)",
       'posttranslational protein folding (GO:0051087)',"'de novo' protein folding (GO:00064583)",
       'posttranslational protein folding (GO:00510844)',"'de novo' protein folding (GO:00064588)",
       'posttranslational protein folding (GO:00510855)',"'de novo' protein folding (GO:00064511)",
       'posttranslational protein folding (GO:00510866)',"'de novo' protein folding (GO:000645822)",
       'posttranslational protein folding (GO:00510877)',"'de novo' protein folding (GO:000645833)")

FE<-c(5,10,15,20,25,35,10,15,5,10,15,20,25,35,10,15)
FDR<-c(76,23,45,67,56,45,78,34,76,23,45,67,56,45,78,34)
d<-data.frame(BIO,FE,FDR,stringsAsFactors = F)

# Libraries
library(ggplot2)
library(dplyr)


# Most basic bubble plot
d %>%
  arrange(desc(FDR)) %>%
  ggplot(aes(x=FE, y=BIO, size=FE, color=FDR)) +
  scale_x_continuous(limits = c(NA,50))+
  geom_point(alpha=0.5) +
  scale_size(range = c(.1, 24), name="Population (M)")

输出:

正如您现在看到的,您有更多的空间。例如,如果要将绘图导出到.png,将保持相同的尺寸,只需注意在ggsave()中使用正确的widthheight值即可。

票数 2
EN

Stack Overflow用户

发布于 2020-08-29 20:48:50

罪魁祸首似乎是BIO中的第一个条目。它真的意味着让posttranslational protein folding (GO:0051084)重复两次吗?如果您清理数据标签,那么您可以得到一个更宽的图,而分配给y轴标签的空间更少(因为超长的标签是固定的)。

代码语言:javascript
复制
BIO<-c('posttranslational protein folding (GO:0051084)',"'de novo' protein folding (GO:0006458)",
       'posttranslational protein folding (GO:0051085)',"'de novo' protein folding (GO:0006451)",
       'posttranslational protein folding (GO:0051086)',"'de novo' protein folding (GO:00064582)",
       'posttranslational protein folding (GO:0051087)',"'de novo' protein folding (GO:00064583)",
       'posttranslational protein folding (GO:00510844)',"'de novo' protein folding (GO:00064588)",
       'posttranslational protein folding (GO:00510855)',"'de novo' protein folding (GO:00064511)",
       'posttranslational protein folding (GO:00510866)',"'de novo' protein folding (GO:000645822)",
       'posttranslational protein folding (GO:00510877)',"'de novo' protein folding (GO:000645833)")

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63647066

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档