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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With