2016-10-28 2 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()