[R] Changing default plot behaviour

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Wed Apr 9 17:25:15 CEST 2008


> How would I make the default behaviour of my plots produce output such
> as the following (i.e. tick marks inside on all axes, labels only on two
> (arbitrary?) sides) without needing the five additional commands each
> time?
> 
> plot(1:10, axes=FALSE)
> axis(1, tcl=0.5)
> axis(2, tcl=0.5)
> axis(3, tcl=0.5, labels=FALSE)
> axis(4, tcl=0.5, labels=FALSE)
> box()

Use a custom plotting function, e.g.
myplot <- function(..., sidesforlabels)
{
   #sidesforlabels should be a numeric vector containing the sides that 
you want labels on
   plot(..., axes=FALSE)
   par(tcl=0.5)
   for(i in 1:4)
   {
      axis(i, labels=i %in% sidesforlabels)
   }
   box()
}

myplot(1:10, sidesforlabels=1:2)

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}



More information about the R-help mailing list