ggplot에서 범례 제목 제거
다음에서 범례 제목을 제거하려고합니다 ggplot2
.
df <- data.frame(
g = rep(letters[1:2], 5),
x = rnorm(10),
y = rnorm(10)
)
library(ggplot2)
ggplot(df, aes(x, y, colour=g)) +
geom_line(stat="identity") +
theme(legend.position="bottom")
나는 이 질문을 보았고 거기에 어떤 해결책도 나를 위해 일하지 않는 것 같습니다. 대부분은 어떻게 opts
deprecated되고 theme
대신 사용 하는지에 대한 오류를 제공합니다 . 나는 또한 다양한 버전을 시도했습니다 theme(legend.title=NULL)
, theme(legend.title="")
, theme(legend.title=element_blank)
, 등 일반적인 오류 메시지는 다음과 같습니다
'opts' is deprecated. Use 'theme' instead. (Deprecated; last used in version 0.9.1)
'theme_blank' is deprecated. Use 'element_blank' instead. (Deprecated; last used in version 0.9.1)
ggplot2
0.9.3 버전이 출시 된 이후 처음으로 사용 하고 있으며 일부 변경 사항을 탐색하기가 어렵습니다.
거의 완료되었습니다. 추가하세요. theme(legend.title=element_blank())
ggplot(df, aes(x, y, colour=g)) +
geom_line(stat="identity") +
theme(legend.position="bottom") +
theme(legend.title=element_blank())
R 용 Cookbook의이 페이지에서는 범례를 사용자 지정하는 방법에 대한 자세한 내용을 제공합니다.
이것도 작동하며 범례 제목을 변경하는 방법도 보여줍니다.
ggplot(df, aes(x, y, colour=g)) +
geom_line(stat="identity") +
theme(legend.position="bottom") +
scale_color_discrete(name="")
들어 Error: 'opts' is deprecated
. theme()
대신 사용하십시오 . (소멸, 마지막 버전 0.9.1에서 사용) '나 교체 opts(title = "Boxplot - Candidate's Tweet Scores")
와 함께 labs(title = "Boxplot - Candidate's Tweet Scores")
. 작동했습니다!
참고 URL : https://stackoverflow.com/questions/14771546/remove-legend-title-in-ggplot
'code' 카테고리의 다른 글
Gradle에서 한 곳에서 공통 종속성을 어떻게 선언합니까? (0) | 2020.08.19 |
---|---|
데이터 프레임의 행을 벡터로 변환 (0) | 2020.08.19 |
CSS calc ()에서 vh 마이너스 픽셀을 사용할 수 있습니까? (0) | 2020.08.19 |
CSV / Excel에 가장 적합한 타임 스탬프 형식? (0) | 2020.08.18 |
람다 식으로 stream (). map (…)을 디버깅하는 방법은 무엇입니까? (0) | 2020.08.18 |