Reputation: 10865
For example, I have the following simple command:
x<-rnorm(2000, 0, 30)
hist(x)
But the graph shows a gap between the line y=0
and the x-axis. I want it to be shown in the normal format, where the two axes touch on each other at a particular point (x0, y0)
which I can specify arbitrarily. What is the option in R
to do that?
Thank you.
Upvotes: 0
Views: 1641
Reputation: 173707
I think the easiest way to do this is simply to draw it using box
, since plot.histogram
skips much of the plotting setup that would allow you to pass the appropriate par
settings directly:
x<-rnorm(2000, 0, 30)
hist(x)
box(bty = "l")
See the section in par
on bty
for the possible options.
Upvotes: 2
Reputation: 16277
One way is to plot the x-axis separately and use line
to align it with the 0 coordinate.
loc <- hist(x, xaxt="n",bty="l")
axis(1, at=loc$breaks,line=-.75)
Upvotes: 2
Reputation: 23938
You can specify xlim
and ylim
in hist
.
Check
?hist
AND
hist(x, xlim = c(-100, 100), ylim = c(0, 500))
Upvotes: 0