在R中的密度图中向x轴添加更详细的刻度线

时间:2014-11-17 21:36:31

标签: r axes density-plot

使用此编码解决了这个问题。

使用包格:

  

xticks = c(0.0,0.043,0.052,0.173,0.178,0.200,0.360,0.0,0.1,0.2,0.3,0.4,0.5)

     

yticks = c(0,5,10,15)

     

densityplot(〜Wart,group = Species,data = datum,xlab =" Wart to spot ratio",ylab =" Frequency&#34 ;, scales = list(x = list(at) = xticks),y = list(at = yticks)))

1 个答案:

答案 0 :(得分:0)

除非你有什么理由需要格子,否则你也可以用基本图形制作密度图,然后axis()就可以了:

x <- rnorm(1000)
plot(density(x))
axis(side=1, at=c(-1, 1))

<强>更新

这里有三个发行版:

x <- rnorm(1000)
y <- rnorm(1000, -1)
z <- rnorm(1000, 1)

plot(density(x), xlim=range(x, y, z))
axis(side=1, at=c(-1, 1))

lines(density(y), col="red")
lines(density(z), col="blue")