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) –