2016-11-13 235 views

回答

1

你可以用2元数字矢量的位置,这样的:

p+theme(legend.position=c(0.85,0) 

问题是,它就会重叠绘图区域。

如果你想迫使它在一个水平线上,你可以添加:

p+guides(fill = guide_legend(nrow = 1)) 

output

编辑

我用plot.margin扩大区域在底部,你可以玩参数:

p+ 
guides(fill = guide_legend(nrow = 1))+ 
theme(plot.margin=unit(c(1,1,4,0.5),"cm"))+ 
theme(legend.position=c(0.85,-0.7)) 

enter image description here

OR

p+ 
    theme(plot.margin=unit(c(1,1,4,0.5),"cm"))+ 
    theme(legend.position=c(0.85,-0.7) 

enter image description here

注意

使用Rstudio,当我出口在一定宽度图像*高我不明白传说,但如果我拖动和佐治st出口之前的观点如下,它的工作原理。

enter image description here

+0

谢谢!很高兴知道!但我真的需要绘图区外的传奇......如果你做1.3而不是0.85,会发生什么? –

+1

@GiovanniAzua我编辑了答案,请检查一下你是否在寻找。 – OmaymaS

+0

再次感谢您!我试过了,但我无法得到我想要的传说。当我指定绘图宽度以外的坐标时,图例消失。 –