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

查看:345
本文介绍了设置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).

推荐答案

您可能希望图形参数xaxsyaxs具有样式"i":

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 两端的百分比,然后找到一个 轴带有适合的漂亮标签 在扩展范围内.风格"i" (内部)只是找到一个轴 适合的漂亮标签 原始数据范围.样式"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天全站免登陆