设置 R 绘制 x 轴以在 y=0 处显示 [英] Set R plots x axis to show at y=0

查看:43
本文介绍了设置 R 绘制 x 轴以在 y=0 处显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常当我绘制一些 R 线图并设置 ylim=c(0,some_value) 时,x 轴和 y=0 之间的空间很小.

Usually when I plot some R line plot and set ylim=c(0,some_value), there is small space between the x axis and y=0.

我希望 y 轴准确地显示在 y=0 处,因此点 (x,0) 将绘制在 y 轴上(而不是上方).

I would like the y axis to show exactly at y=0 so points (x,0) will be plotted on the y axis (and not above).

推荐答案

您可能需要样式为i"的图形参数 xaxsyaxs:

You probably want the graphical parameters xaxs and yaxs with style "i":

plot(1:10, rnorm(10), ylim=c(0,10), yaxs="i")

?par:

xaxs:轴间距的样式用于 x 轴的计算.可能的值为r"、i"、e"、s",d".款式一般是受数据范围控制或xlim,如果给出.样式r"(常规)首先将数据范围扩大 4每一端的百分比,然后找到一个带有漂亮标签的轴适合扩展范围内.样式我"(内部)只找到一个轴适合的漂亮标签原始数据范围.样式s"(标准)找到一个漂亮的轴原始数据所在的标签范围适合.样式e"(扩展)是类似于样式s",除了它也是确保有空间在边界内绘制符号盒子.样式d"(直接)指定当前轴应该用于随后的情节.(只有r"和i"样式目前已实现)

xaxs: The style of axis interval calculation to be used for the x-axis. Possible values are "r", "i", "e", "s", "d". The styles are generally controlled by the range of data or xlim, if given. Style "r" (regular) first extends the data range by 4 percent at each end and then finds an axis with pretty labels that fits within the extended range. Style "i" (internal) just finds an axis with pretty labels that fits within the original data range. Style "s" (standard) finds an axis with pretty labels within which the original data range fits. Style "e" (extended) is like style "s", except that it is also ensures that there is room for plotting symbols within the bounding box. Style "d" (direct) specifies that the current axis should be used on subsequent plots. (Only "r" and "i" styles are currently implemented)

yaxs:用于 y 轴的轴间隔计算样式.请参阅上面的 xaxs.

yaxs: The style of axis interval calculation to be used for the y-axis. See xaxs above.

这篇关于设置 R 绘制 x 轴以在 y=0 处显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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