我怎样才能在R图的左边角落出现零刻度? [英] How can I make the zero tick appear in the lefthand corner in R plots?

查看:134
本文介绍了我怎样才能在R图的左边角落出现零刻度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您使用'plot'命令在R中生成图时,并将左侧x轴限制设置为零时,例如

  plot(x = c(1:10),y = c(1:10),xlim = c(0,10),ylim = c(0,10))


我可以通过手动猜测偏移量并相应地调整底部和左侧轴限制来获得我想要的图形:

  plot(x = c(1:10),y = c(1:10),xlim = c(0.38,10), ylim = c(0.38,10))

但是问题是,我必须手动执行此操作每一个图,看起来过多。



是否有一个par-type设置来消除这个边距?

在调用 plot()时, xlim ylim 默认填充(扩展)4%。要抑制此行为,请设置 xaxs =i和/或 yaxs =i

有关更多详情,请参阅帮助页面 par

 (x = c(1:10),y = c(1:10)),xlim = c(0,10),ylim = c(0,10),xaxs =i, yaxs =i)


When you generate plots in R with the 'plot' command, and set the left side x-axis limit to zero, with, e.g.

plot(x=c(1:10), y=c(1:10), xlim=c(0,10), ylim=c(0,10))

R, for reasons which are not apparent to me, puts a bunch of extra space between the point (0,0) and the bottom lefthand corner (also at the top).

I can get the graph I want by manually guessing the offsets, and adjusting the bottom and left axis limits accordingly:

plot(x=c(1:10), y=c(1:10), xlim=c(0.38,10), ylim=c(0.38,10))

But the problem is, I have to do this manually for each graph, which seems excessive.

Is there a par-type setting for removing this margin?

解决方案

In calls to plot(), both xlim and ylim are by default padded (extended) by 4%. To suppress this behavior, set xaxs = "i" and/or yaxs = "i".

For more details, see the help page for par.

plot(x=c(1:10), y=c(1:10), xlim=c(0,10), ylim=c(0,10), xaxs="i", yaxs="i")

这篇关于我怎样才能在R图的左边角落出现零刻度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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