我正在尝试在 a 中添加多个图例geom_vlines
,facet_wrap
但我无法将颜色保留在图表中。我已经添加aes
了每个vline
,但它们看起来是灰色的。
ggp +
geom_vline (aes(xintercept = median(overall_vector), color = "red"), linetype = "dashed") +
geom_vline (aes(xintercept = quantile(overall_vector,0.80), color = "green"), linetype = "dashed") +
geom_vline (aes(xintercept = quantile(overall_vector,0.20), col = "orange"), linetype = "dashed") +
scale_color_manual(name = "statistics", values = c(median = "red", "p 80" = "green", "p 20" = "orange"))
如果我拿出aes
它只是不显示传说。如果我aes
只保持中位数,也会发生同样的情况vline
ggp +
geom_vline (xintercept = median(overall_vector), color = "red", linetype = "dashed") +
geom_vline (xintercept = quantile(overall_vector,0.80), color = "green", linetype = "dashed") +
geom_vline (xintercept = quantile(overall_vector,0.20), col = "orange", linetype = "dashed") +
scale_color_manual(name = "statistics", values = c(median = "red", "p 80" = "green", "p 20" = "orange"))
图例仅显示我是否添加aes
至少 1 vline
,但它vline
会变成灰色。
ggp +
geom_vline (xintercept = median(overall_vector), color = "red", linetype = "dashed") +
geom_vline (xintercept = quantile(overall_vector,0.80), color = "green", linetype = "dashed") +
geom_vline (aes(xintercept = quantile(overall_vector,0.20), col = "orange"), linetype = "dashed") +
scale_color_manual(name = "statistics", values = c(median = "red", "p 80" = "green", "p 20" = "orange"))
谢谢!