The ggplot2 package defaults to showing grids due to its 'Grammar of Graphics' philosophy. And lattice has a function panel.grid() you can use in custom panel functions.
By the way, there are search functions for help as e.g. help.search("something") and there is an entire package called sos to make R web searches more fruitful.
发布评论
评论(5)
grid 命令似乎可以在任何需要的地方绘制网格线。我通常使用 abline 将线条精确地放置在我想要的位置。例如,
祝你好运!
The grid command seems to draw grid lines where-ever it feels like. I usually use abline to put lines exactly where I want them. For example,
Good luck!
请参阅适用于标准图形的
help(grid)
- 简短示例:lattice 有一个函数
panel.grid()
您可以在自定义面板功能中使用。顺便说一句,有一些帮助搜索功能,例如
help.search("something")
并且有一个名为 sos 使 R 网络搜索更加富有成效。See
help(grid)
which works with standard graphics -- short example:The ggplot2 package defaults to showing grids due to its 'Grammar of Graphics' philosophy. And lattice has a function
panel.grid()
you can use in custom panel functions.By the way, there are search functions for help as e.g.
help.search("something")
and there is an entire package called sos to make R web searches more fruitful.如果您不使用自定义刻度间隔,则可以直接通过
plot()
命令控制网格和坐标区参数:plot.default()
文档提供了更多信息关于这些参数。If you are not using a custom tick interval, you can control the grid and axes parameters directly from the
plot()
command:The
plot.default()
documentation provides more information about these parameters.我同意cbare的观点。
使用
abline
仅在您真正需要的地方绘制线条。我上一个代码的示例:
请记住:
v
用于垂直线。h
表示水平。利用命令
lty
获取虚线color
为浅色线,以获得“无重网格”。
I agree with cbare.
Use
abline
to draw lines only where you really need.Example from my last code:
remember that:
v
is for vertical lines.h
for horizontal.exploit the commands
lty
for dotted linecolor
for light coloured linein order to obtain "no heavy grid".
另一种选择是对垂直和水平网格线使用 axis 函数:
创建于 2022 年 8 月 20 日,使用 reprex v2.0.2
您可以使用
at
参数指定网格线的位置。Another option is using the axis function for vertical and horizontal grid lines:
Created on 2022-08-20 with reprex v2.0.2
You can specify the position of the grid lines using the
at
argument.