2011-08-19 12 views
13

opts()の呼び出しで示さ水平ように右側ではなく、底部に、上下方向に配置される凡例の次のプロット結果の作成を有していない。)は(OPTSを用い凡例位置/方向を変更しない効果

dat <- data.frame(x = runif(10), y = runif(10), 
        grp = rep(letters[1:2],each = 5)) 

ggplot(data = dat, aes(x = x, y = y, colour = grp)) + 
    geom_point() + 
    opts(legend.position = "bottom", legend.direction = "horizontal") + 
    theme_bw() 

enter image description here

凡例を正しい場所に取得するにはどうすればよいですか?

答えて

20

theme_bw()は、opts()の呼び出しの後に配置され、いくつかのデフォルトをリセットします。

ggplot(data = dat, aes(x = x, y = y, colour = grp)) + 
    geom_point() + 
    theme_bw() + 
    opts(legend.position = "bottom", legend.direction = "horizontal") 

::ちょうどtheme_bw()opts()前を置き、バージョン0.9.2 optsのでthemeによってreplacedされています:

theme(legend.position = "bottom", legend.direction = "horizontal") 

enter image description here

+1

+1卑劣な...... –

関連する問題