2016-04-27 22 views
0

凡例の距離をx軸に縮小したいのですが、その方法を見つけることができません。出来ますか?ggplot2:凡例の距離をx軸に合わせますか?

例コード:

library(ggplot2) 

ggplot(mtcars, aes(x = gear, y = mpg, fill = gear)) + 
    geom_bar(stat = "identity") + 
    theme(legend.position = "bottom") 

答えて

3

だけのマージン値を調整します。

ggplot(mtcars, aes(x = gear, y = mpg, fill = gear)) + 
    geom_bar(stat = "identity") + 
    theme(legend.position = "bottom",legend.margin=unit(-.05,"cm")) 
+0

パーフェクト!ありがとう! – ChristianL

関連する問題