R的直方图-x轴未正确居中 [英] Histogram in R - x-axis not centered properly
问题描述
我有一个通过简单输入而得出的值列表d
的直方图
I have a histogram from a list d
of values that I make by simply typing
hist(d)
这就是我得到的:
如何使x轴一直延伸到该图的原点(左下角)?为什么截止到-0.4?
How can I make it such that the x-axis extends all the way left to the origin of this plot (the bottom left corner)? Why does it cut off at -0.4?
推荐答案
到目前为止,宏的答案是最简单的方法.但是,如果您真的对hist
的默认行为不满意(真的,我想这是axis
的默认行为),则始终可以抑制轴并自己绘制它们:
Macro's answer is by far the simplest route. However, if you really are unhappy with with the default behavior of hist
(really, it's the default behavior of axis
I suppose) you can always suppress the axes and draw them yourself:
set.seed(123)
d <- rnorm(1000)
hist(d,axes = FALSE)
axis(1,at = seq(-3,3,1),labels = TRUE,pos = 0)
axis(2,pos = -3)
至于为什么?",绘制轴的默认值必须设置为某种值,因此,下面有很多代码试图确保轴和刻度标签为漂亮".不管是谁写的,它的敏感性.总的来说,我认为它做得很好,但是当然并非所有人都同意.
As for the "why?", the defaults for drawing axes have to be set at something, and so there's a lot of code under there that tries pretty hard to ensure that the axis and tick labels are "pretty" according to the sensibilities of, well, whoever wrote it. In general, I think it does a good job, but of course not everyone agrees.
这篇关于R的直方图-x轴未正确居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!