2017-01-03 54 views
0

我正尝试用ggplot2()构建一个bubbleplot。我想增加图表的边际,但是,尽管我已经尝试了几个解决方案,但都没有工作。增加空白bubbleplot ggplot2()

图表是folling

enter image description here

代码I'm使用如下

ggplot(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)) 

这里是数据集

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 

我将不胜感激建议

+0

类似'+ scale_x_continuous( expand = c(0.1,0))+ scale_y_continuous(expand = c(0.1,0))'?如果不是这样,你至少必须给出一个可重复的例子,并澄清那些不起作用的“几种解决方案”。 – Axeman

+0

这是什么数据?这个'Var'&'Var2'在哪里?这个'Var3'是什么? – hrbrmstr

+0

亲爱的Axeman和hrbrmstr - 我已经用数据集编辑过这个帖子 – FranciscoC

回答

0

我找到答案,

只需添加+ scale_y_discrete(展开= 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) 
0

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

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

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

这不会避免气泡被切断。 – Axeman