本文介绍了网格线与轴上的刻度一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我很尴尬地问这个简单的问题,但是每当我创建一个情节时,我就一直在思考:
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")
我想将网格定位在标记轴的位置,即 x 轴上的 2、4、6、8、10 以及 y 轴上的类似 3、4、5、6、7、8.
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:
推荐答案
来自 ?grid
对 nx
和 ny
参数的描述:
From ?grid
description of the nx
and ny
arguments:
当为 NULL 时,默认情况下,网格与网格上的刻度线对齐对应的默认轴(即 axTicks 计算的刻度线)
plot (x = 1:10, y = rnorm (10, 5, 2))
grid (NULL,NULL, lty = 6, col = "cornsilk2")
这篇关于网格线与轴上的刻度一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!