2
我想着色虚线,它们是两个相应的类别的平均值,具有相同的颜色由ggplot使用默认调色板的填充分布:颜色平均线ggplot
Click here to view the distribution
这是所使用的代码:
library(ggplot2)
print(ggplot(dati, aes(x=ECU_fuel_consumption_L_100Km_CF, fill=Model))
+ ggtitle("Fuel Consumption density histogram, by Model")
+ ylab("Density")
+ geom_density(alpha=.3)
+ scale_x_continuous(breaks=pretty(dati$ECU_fuel_consumption_L_100Km_CF, n=10))
+ geom_vline(aes(xintercept = mean(ECU_fuel_consumption_L_100Km_CF[dati$Model == "500X"])), linetype="dashed", size=1)
+ geom_vline(aes(xintercept = mean(ECU_fuel_consumption_L_100Km_CF[dati$Model == "Renegade"])), linetype="dashed", size=1)
)
谢谢大家提前!
谢谢你,第二个选项运作良好;但我不得不删除一个额外的传说出现[如何关闭一些传说](http://stackoverflow.com/questions/14604435/turning-off-some-legends-in-a-ggplot) –