我有兩個數字向量,我想繪製每個+正常曲線的直方圖。在同一圖上的兩個直方圖 - 不重疊
首先數值向量:
dput(X)
structure(c(18.9006028896526, 15.2623176606927, 23.9827366796017,
18.6674504871855, 33.8321828287622, 106.070218436199, 33.7827125058274,
138.544803100033, 98.8988553851087, 84.6705010348182, 90.0070387381623,
97.842536232733, 6.75830201534835, 24.105734944894, 18.9289005033733,
107.837417018034, 91.2295363960887, 120.394907406909, 23.4284311509232,
27.936658956423), .Names = c("A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T"))
第二數值向量:
> dput(Y)
structure(c(4.98024718191362, 4.97784623179944, 37.54860832645,
34.0616843614727, 146.39674720645, 17.3962674768585, 40.896642118419,
71.7799735926384, 46.5749573881639, 39.3924128572005, 137.396714992547,
111.856816465825, 80.8041773807388, 24.1694521970975, 15.700639434151
), .Names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"))
那些載體的長度不同。我想申請類似下面我用正態曲線的單直方圖和估計一個代碼:
h<-hist(X, breaks=25, col="green", xlab="Graph",
main="Histogram and Normal Curve", xlim = c(0, 100))
xfit<-seq(min(X),max(X),length=40)
yfit<-dnorm(xfit,mean=mean(X),sd=sd(X))
yfit <- yfit*diff(h$mids[1:2])*length(X)
lines(xfit, yfit, col="blue", lwd=2)
所需的輸出:
上的其他解決方案,那麼究竟是什麼問題呢?什麼是期望的輸出? – MrFlick
我不知道如何將兩個直方圖放在同一個圖上。我的意思是我希望看到每個矢量的條形圖彼此靠近 –
「在同一個圖上」對您而言意味着什麼?你可以上傳你以後的草圖嗎?這不是很清楚。直方圖不是相互結合良好的圖形。 – MrFlick