0
ggplot의 전설 기호에 영향을 미치는 - 도시와 마을을라벨은 내가 두 개의 서로 다른 변수 데이터 세트가
내가 그들을 음모와stat_smooth
두 회귀 라인을 추가하면 범례 기호가 제대로 표시되지 않습니다 (그들은 '두 가지로 나타납니다
A의) :
ggplot(metrics, aes(x=popDensity, y= TPB, color = factor(type))) + geom_point() +theme_minimal() + stat_smooth(method = "lm", se = FALSE) +
geom_label_repel(aes(label= rownames(metrics)), size=3) +
theme(axis.title = element_text(family = "Trebuchet MS", color="#666666", face="bold", size=12)) +
labs(x = expression(paste("density ", km^{2})), y = expression(paste("rating[![enter image description here][1]][1]")))+
theme(legend.position="top", legend.direction="horizontal")
다음은 결과입니다 : 나는 geom_label_repel
기능을 제거 할 때
그러나, 내가 필요로하는 전설 기호를 얻을 -하지만 물론 레이블이 표시되지 않습니다.
ggplot(metrics, aes(x=popDensity, y= TPB, color = factor(type))) + geom_point() +theme_minimal() + stat_smooth(method = "lm", se = FALSE) +
#geom_label_repel(aes(label= rownames(metrics)), size=3) +
theme(axis.title = element_text(family = "Trebuchet MS", color="#666666", face="bold", size=12)) +
labs(x = expression(paste("density ", km^{2})), y = expression(paste("rating")))+
theme(legend.position="top", legend.direction="horizontal")
왜 이런 일이 발생 않으며,이 문제에 대한 알려진 해결 방법은? 또한 범례 제목의 제목을 수동으로 변경하는 방법이 있습니까? 나는 오류를
+ theme(legend.title = "title"
사용) 만 얻을 시도 :
Error in (function (el, elname) :
Element legend.title must be a element_text object.
샘플 데이터 :
> dput(metrics)
structure(list(popDensity = c(4308, 27812, 4447, 5334, 4662,
2890, 24623, 5847, 1689, 481, 4100), TPB = c(1, 0.5, 1, 1.3,
0.8, 4, 0.2, 0.7, 5, 4, 2), type = c("City", "City", "City",
"City", "City", "City", "Town", "Town", "Town", "Town", "Town"
)), .Names = c("popDensity", "TPB", "type"), row.names = c("City1",
"City2", "City3", "City4", "City5", "City6", "Town1", "Town2",
"Town3", "Town4", "Town5"), class = "data.frame")
감사합니다. 전설 제목을 '인자 (유형)'에서 다른 것으로 변경해야합니까? –
'+ scale_colour_manual (name = "something else")' –
''f (...)에서 오류가 발생했습니다 : 인수 "values"가 누락되었습니다. 기본값은 없습니다. –