水平网格不匹配y轴刻度

时间:2012-02-12 01:14:10

标签: r

我有以下数据:

x=c(2.880262,3.405859,3.613575,3.744480,3.682059,3.694075,3.758320,4.034290,4.202741,4.309383,4.996279,5.981309,5.103148,4.926363,4.696024,5.522913,5.330382,4.434304,5.154567,6.247156,8.612752,9.996526,9.606994,10.303496,5.954970,5.688171,6.340349,6.252854,6.355642,5.988570,7.317148,11.664384,14.231579,16.489029,23.100640,20.280043,21.562793,24.311327,23.735198,23.796386,23.118181,23.269722,19.886981,20.000975,19.967642,24.278910,17.447721,14.536114,20.646378,19.096832,20.258060,19.803196)
y=1:52
w=c(-2784,-2897,-2897,-2066,-2466,-2466,-2466,-2466,-2102,-2102,-2102,-2202,-2094,-2094,-2094,-2094,-1691,-1691,-1691,-1691,-1691,-1674,-1774,-1774,-2019,-2019,-2019,-2019,-2019,-1988,-1988,-1988,-1988,-1988,-1888,-1888,-1888,-1888,-1888,-1888,-1888,-1488,-2051,-2051,-2051,-2051,-2315,-2315,-2315)
v=1:49

当我尝试绘制这些时,我的网格与刻度线不匹配。有没有办法在基地解决这个问题?

plot(y,x,type='l',col='blue',log='y')
grid(NA,NULL)

结果情节:

Image of plot with grid issue

另一个情节:

plot(v,w,type='l',yaxt='n')
grid(NA,NULL)
axis(2,pretty(w),format(pretty(w)/1000,big.mark=','))

结果:

Image of plot with grid issue

我把两者都放了,因为我使用不同的技术来标记y轴,一个是日志图,而另一个不是。顺便说一句,我有数百个其他数据集,它们通过刻度线放置网格线。只有这两个不匹配网格到刻度。

1 个答案:

答案 0 :(得分:2)

对于第一个图,只需使用equilogs=F

对于第二个图,由于您使用的是非默认轴刻度,我认为您必须像abline中所说的那样求助于?grid。祝你好运!