[R] Snap axes to origin rather than around it
Marc Schwartz
marc_schwartz at me.com
Fri Jun 12 14:29:52 CEST 2009
On Jun 12, 2009, at 7:18 AM, Paul Chatfield wrote:
>
> I'm trying to plot a graph where the axes go through 0,0, rather
> than around
> it combined with a box round the graph, so
>
> x<-0:10;y<-0:10
> plot(x,y)
>
> gives me a box but doesn't go through the point 0,0, but stays at a
> distance.
>
> In trying to circumvent this problem, I wrote
>
> plot(x,y)
> axis(1, pos=c(0,0));axis(2,pos=c(0,0))
>
> which gives me axes that go through the origin, but then I can't
> make a box
> round a plot (box() goes again at this fixed distance from the
> origin rather
> than through it)
>
> Any thoughts, ideas gratefully accepted. Perhaps I've been looking
> at it so
> long I'm now missing the obvious! :)
>
> Paul
>
> Any ideas?
See ?par and take note of 'xaxs' and 'yaxs':
x <- 0:10
y <- 0:10
plot(x, y, xaxs = "i", yaxs = "i")
HTH,
Marc Schwartz
More information about the R-help
mailing list