[R] plot feature request

Paul Murrell paul at stat.auckland.ac.nz
Sun Mar 19 22:22:09 CET 2000


hi

[pardon the trashed formatting of the original text]


> When plots are stacked on top of each other, in my area the journals
> like them like this:
>
> 4-| -|
>   | |
> 3-| -|
>   | |
> 2-| -|
>   | |
> 1-| -|
>   | |
>   --+--+--+--+-- --+--+--+--+--
>
> 4-|                     -|
>   |                      |
> 3-|                     -|
>   |                      |
> 2-|                     -|
>   |                      |
> 1-|                     -|
>   |                      |
>   --+--+--+--+--         --+--+--+--+--
>     1  2  3  4    1  2  3  4
>      x axis                  x axis
>
> The axis labels and annotation are eliminated sometimes.
>
> I know that the bottom right plot can be done by
> plot(...,ann=FALSE, axes=FALSE)
> axis(side=1,at=...,labels=FALSE)
> axis(side=2,at=...,labels=TRUE)
> text(x=...,y=...,"x axis")
> This is quite a hassle. (It is tricky to get the scales and
> axis hash mark positions all exactly the same; it is tricky to position
> the annotation)


it should be much easier to position the axis label annotation using mtext()
or title().


> It would be much easier if I could
> - set ann.x and ann.y separately to TRUE/FALSE


you can by specifying the xlab and ylab parameters (xlab="" corresponds to
ann.x = F)


> - set separate arguments labels.x and lables.y to TRUE/FALSE in
> plot() instead of in axis().
>
> Then to get the top right plot I would do:
> plot(..,ann.x=FALSE, ann.y=FALSE, labels.x=FALSE, labels.y=FALSE)
> and the
> bottom right plot would be
> plot(..,ann.x=TRUE, ann.y=FALSE, labels.x=TRUE, labels.y=FALSE)


it should be fairly simple to write a wrapper function to do this.  for
exampe,

my.plot <- function(x, y, at.x, at.y, ann.x, ann.y, labels.x, labels.y)
{
    plot(x, y, axes=F, ann=F)
    axis(1, at=at.x, labels=labels.x)
    axis(2, at=at.y, labels=labels.y)
    # box(bty="l") ?
    title(xlab=if (ann.x) "x axis" else "", ylab=if (ann.y) "y axis" else
"")
}

hope that helps

paul



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list