Skip to content

axis

4 messages · Myriam Abramson, Uwe Ligges

#
I have to draw a phase space graph. Is it possible to draw the axis at
the center at (0,0)? 

TIA
#
Myriam Abramson wrote:
Yes, using axis() with argument "pos", see ?axis. 

Example:

 y <- rnorm(21)
 plot(-10:10, y, axes=FALSE)
 axis(1, pos=0)
 axis(2, pos=0)

 # OK. Looks ugly (the zero). Next try:
 plot(-10:10, y, axes=FALSE) 
 axis(1, pos = 0, at = c(-10, -5, 5, 10))
 yprt <- pretty(y)
 yprt <- yprt[yprt != 0]
 axis(2, pos = 0, at = yprt)


Uwe Ligges
#
Myriam Abramson wrote:
First set up your plot( ...., type = "n").
Then draw the shading using polygon(...., col = "grey"), after that the
lines() and points() to appear in front of it.

Uwe Ligges