-2
我想繪製負二項分佈和泊松分佈以適合我的實際數據,但我不知道如何繪製圖例,誰可以幫助我那非常感謝。我的代碼和圖片如下:如何在R中繪製分佈模型時添加圖例ggplot2
ggplot() +
geom_density(aes(a),color="red",lwd=2) +
geom_density(aes(x=rpois(50,1.57)),color="purple",lwd=2) +
geom_smooth() +
geom_density(aes(x=rnbinom(100,size=0.2,mu=1.57)),color="blue",lwd=2) +
geom_smooth() +
coord_cartesian(xlim=c(0,10)) + labs(x="count")
我的數據在這裏上傳: https://www.jianguoyun.com/p/DSHXKgMQm5CLBhiKjCc。
謝謝你的幫助。 「二項式」之後的括號可以在參數「顏色」之前加上。 – user4672728
@ user4672728我修復了錯字 – MrFlick