我有以下密度图:
我的输入数据如下:
PA <- c(3028.0,3083.0,2958.0,2889.0,2758.0,2815.0,2877.0,3145.0,3072.0,3056.0,2856.0,2934.0,3112.0,2913.0,2837.0)
我使用以下命令制作我的情节:
plot(density(PA), main="Avidin PA")
abline(v=2913, col="red")
我添加了一条红色的参考线,如何在截取情节时让参考线停止?
答案 0 :(得分:2)
我们需要做一些工作来弄清楚给定x值的密度大约是多少。一旦我们有了,我们可以使用lines命令绘制感兴趣的线。这应该是一个开始:
PA <- c(3028.0,3083.0,2958.0,2889.0,2758.0,2815.0,2877.0,3145.0,3072.0,3056.0,2856.0,2934.0,3112.0,2913.0,2837.0)
den.PA <- density(PA)
lineat = 2913
# Find which x value that the density was computed
# for is the closest to the x value we want a line at
lineheight <- den.PA$y[which.min(abs(den.PA$x - lineat))]
plot(den.PA, main="Avidin PA",)
lines(c(lineat, lineat), c(0, lineheight), col = "red")