2016-10-28 20 views
0

ggplotで凡例のタイトルのアラインメントを変更しようとしています。具体的には、左側(デフォルト)ではなく、凡例キーの上に水平凡例のタイトルを入れたいと思います。 theme(legend.title.align)を使用できるはずですが、その機能は何の効果もないようです。私は、デフォルトで垂直に整列した右の凡例を、成功なしで使ってみました。 mtcarsggplotでの凡例のタイトルの整列

# Horizontal legend placed below plot 
ggplot(mtcars, aes(x = hp, y = mpg, color = factor(cyl))) + 
geom_point() + 
theme(legend.position = 'bottom', 
     legend.direction = 'horizontal') 

# Vertical legend right of plot with attempt at right alignment 
ggplot(mtcars, aes(x = hp, y = mpg, color = factor(cyl))) + 
    geom_point() + 
    theme(legend.position = 'right', 
    legend.direction = 'vertical', 
    legend.title.align = '1') 

を用いて以下

例は、特に水平凡例の上にタイトルを配置するため、ggplotにlegend.titleの位置を変更する方法はありますか?

答えて

0

guides(color = guide_legend(title.position = 'top')私の問題を解決しました。あなたはタイトル整列を調整できないと思います。theme()

関連する問題