增加利润bubbleplot ggplot2()

时间:2017-01-03 12:33:05

标签: r ggplot2

我正在尝试使用ggplot2()构建一个气泡图。我想增加图表的边距,但是,尽管我已经尝试了几种解决方案,但是没有工作。

图表是愚蠢的

enter image description here

我使用的代码如下

  Var1 Var2       Var3
1   T_1   T1   5.014627
2  T_12   T1   3.523363
3   T_3   T1   4.583498
4   T_7   T1 220.842570
5   T_9   T1  96.106181
6   T_1   T2 156.281533
7  T_12   T2   4.296740
8   T_3   T2  17.103414
9   T_7   T2  80.447975
10  T_9   T2  54.612852
11  T_1   T3  79.213905
12 T_12   T3   4.548642
13  T_3   T3  65.326722
14  T_7   T3  67.283008
15  T_9   T3 220.642854
16  T_1   T4 268.852172
17 T_12   T4 306.466099
18  T_3   T4  66.043928
19  T_7   T4  30.752214
20  T_9   T4  38.575883
21  T_1   T5 253.413462
22 T_12   T5   3.289762
23  T_3   T5   5.201571
24  T_7   T5 106.649741
25  T_9   T5   2.034214

这是数据集

if (getSupportFragmentManager().findFragmentById(R.id.some_layout_id) != null)

我非常感谢建议

2 个答案:

答案 0 :(得分:0)

您是否尝试过plot.margin()或legend.margin()?例如:

plot + theme(..., legend.margin = unit(1, "cm")) 

plot + theme(..., panel.margin = unit(1, "cm")) 

答案 1 :(得分:0)

我找到了答案,

只需添加+ scale_y_discrete(expand = c(0,1.5)。

例如:

gplot(data,aes(Var1,Var2,fill=Var1))+
  geom_point(aes(size=Var3/3),shape=21,show.legend = FALSE)+  theme(axis.title.y=element_text(vjust=0))+
  scale_size_identity()+
  theme(panel.grid.major=element_line(linetype=2,color="black",size=0.1),
  axis.text.x=element_text(angle=90,hjust=1,vjust=0))+scale_y_discrete(expand=c(0, 1.5)
相关问题