网格线与坐标轴上的刻度一致 [英] Grid line consistent with ticks on axis

查看:418
本文介绍了网格线与坐标轴上的刻度一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很尴尬地问这个简单的问题,但是每当我创建一个情节时,我一直在嘲笑我的思想:

 <$ c $ (10,10,lty = 6,col =cornsilk2)

我想将网格定位在轴标记的位置,即在x轴处为2,4,6,8,10,并且类似地3 ,4,5,6,7,8在y轴上。





我希望自动执行该过程,因为每当绘图大小更改默认标签行为更改时。看到下面的图:



?grid 的描述 nx ny 参数:


根据默认值,网格与
对应的默认轴上的刻度线对齐(即由axTicks计算的tickmarks)



  plot(x = 1:10,y = rnorm(10,5,2))
grid(NULL,NULL,lty = 6,col =cornsilk2)


I am embarrassed to ask this simple question, but has been in kicking my mind for several days whenever I create a plot:

plot (x = 1:10, y = rnorm (10, 5, 2))
grid (10,10, lty = 6, col = "cornsilk2")

I want to position the grids right at where axis are labelled, i.e. at 2, 4, 6, 8, 10 in x axis and similarly 3, 4, 5, 6, 7, 8 in y axis.

I want to automate the process as whenever the plot size changes the default label behaviour changes. See the following plot:

解决方案

From ?grid description of the nx and ny arguments:

When NULL, as per default, the grid aligns with the tick marks on the corresponding default axis (i.e., tickmarks as computed by axTicks)

plot (x = 1:10, y = rnorm (10, 5, 2)) 
grid (NULL,NULL, lty = 6, col = "cornsilk2") 

这篇关于网格线与坐标轴上的刻度一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆