![](/img/trans.png)
[英]How can I synchronize the axes of a frequency polygon on top of a histogram in R?
[英]How do I superimpose a frequency polygon on top of a histogram in R using lines?
我是 R 和 RStudio 的初學者,我正在嘗試使用“汽車”數據集在直方圖之上制作頻率多邊形。
attach(cars)
hist(speed)
lines(speed, lwd=2, col = "royalblue")
我需要的是在直方圖頂部正確出現的點。 我見過這個使用繪圖,但我無法在我的代碼中使用它。
嘗試
par(mfrow=c(2,2))
hist(speed)
lines(speed, lwd=2, col = "royalblue")
或者,您可以在 ggplot2 中一次性完成所有操作。 但我需要一個數據樣本和你的腳本。
最好的事物
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.