이 플롯에 범례를 추가하려면 어떻게해야합니까? 다음과 같이ggplot의 분산 밀도 플롯에 범례를 추가하려면 어떻게합니까
내 코드는 다음과 같습니다
d1 = densCols(data4$x, data4$y,
colramp = colorRampPalette(c("navy blue","yellow","firebrick","firebrick"),
space = "Lab"))
ggplot(data4) +
geom_point(aes(x=x, y= y, col = d1), size = 0.1) +
scale_color_identity() +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
labs(x="xaxis", y="yaxis", title="xyz cells") +
theme(plot.title = element_text(hjust = 0.5))
theme(legend.position=c(1,1),legend.justification=c(1,1))
내가 이것과 언급 한 여러 가지 다른 일을 시도했지만 작동하지 않는 이유를 알고하지 않습니다.
미리 도움을 주셔서 감사합니다.
scale_color_identity (가이드 = "범례")를 추가 한 후 Ok. 내 그래프는 다음과 같습니다.
! scale_color_identity(guide = "legend")
을 포맷팅이 작동하면 [{}] 버튼을 대신 사용하십시오. – awiebe
예를 들어 주시면 이해가 가지 않습니다. – Goku