【发布时间】:2019-12-10 22:24:16
【问题描述】:
这是数据集:
d <- tribble(
~priceseg, ~price_n, ~zet_n, ~zet_n2,
"(0,1]", 16, 2, 24,
"(1,3]", 33, 3, 38,
"(3,5]", 33, 2, 25,
"(5,6]", 17, 1, 13,
)
感谢@d.b,这是可视化
ggplot(d) +
geom_col(aes(x = priceseg, y = price_n), fill = ("#F1948A"), colour="black", size = 0.6) +
geom_line(data = d, mapping = aes(x = priceseg, y = zet_n2, group = 1), colour = "#154360", size = 1) +
geom_label(data = d, mapping = aes(x = priceseg, y = price_n, label = price_n), nudge_y = -0.6)
现在,我想在可视化中添加条形图和线条的图例,如下所示:Combined line & bar geoms: How to generate proper legend?
另外,我想在 geom_label 中添加 %。
但不知何故,我无法实现它。有什么帮助吗?
【问题讨论】: