为什么我的传奇不显示?

时间:2016-02-16 19:51:39

标签: r ggplot2

为什么我在绘制此图时不会出现我的传奇?

ggplot(data=baseline_total, aes(x=sighd_rater_total, color="sighd_rater_total")) + 
geom_area(stat="bin", col = 'light blue', fill='light blue') + 
geom_freqpoly(data=baseline_total,aes(x=sighd_tier1_total, color="sighd_tier1_total"), stat = "bin", col = 'dark blue')

1 个答案:

答案 0 :(得分:1)

如果您在aes()内指定颜色(或填充,形状等),则需要在不""的情况下指定颜色(或填充,形状等),以便根据该变量获取图例。 所以这可能会奏效:

ggplot(data = baseline_total, aes(x = sighd_rater_total, colour = sighd_rater_total)) + 
geom_area(stat="bin", colour = "light blue", fill = "light blue") + 
geom_freqpoly(data = baseline_total, aes(x = sighd_tier1_total, colour = sighd_tier1_total), stat = "bin")