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

发布于 2020-08-29 20:45:57
我建议使用scale_x_continuous()来处理x轴的比例限制。下面是示例:
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()中使用正确的width和height值即可。
发布于 2020-08-29 20:48:50
罪魁祸首似乎是BIO中的第一个条目。它真的意味着让posttranslational protein folding (GO:0051084)重复两次吗?如果您清理数据标签,那么您可以得到一个更宽的图,而分配给y轴标签的空间更少(因为超长的标签是固定的)。
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)")

https://stackoverflow.com/questions/63647066
复制相似问题