[R] Legend outside the plot? xpd?
David Winsemius
dwinsemius at comcast.net
Sun Feb 6 08:56:28 CET 2011
On Feb 6, 2011, at 2:41 AM, Matt Cooper wrote:
> Hi All,
>
> BG: Will try be brief. I'd like 3 graphs on a page (below each other
> mfrow=c(3,1)), saved to pdf. The three plot data on the same subject
> so I'm
> having one legend, to the right of the center graph. I'm using
> mar=c(5,15,4,15) to bring the sides in so that the graphs are square
> and not
> stretched wide. To have the graph to the side I'm thinking xpd=T.
> Each graph
> has a number of points and lines overlaid, so plot
> ();lines(),lines(),lines() etc.
>
> The data is somewhat of a subset of a larger set, so I'm limiting
> what is
> being displayed. The lines plot trends of the wider data.
>
> P: With xpd=T, the lines are going right out of the graph boxes to
> the outer
> limit of the plot boundaries, as would be the intended behaviour of
> xpd.
> Goes without saying that this is undesirable.
>
> Q: Is there a better way to achieve what I want? At this stage I
> have xpd=T
> in the par(), and xpd=F in the plot() commands and all the line
> commands,
> just so I can get the legend to actually print...
Why not just use xpd=T inside legend()?
>
> Aside: Given the way I've done this, the lines() are all clipped
> RIGHT at
> the limit of the plot box. So given the plot is called first these
> lines
> leave little coloured dashes on the black of the plot box. To sort
> this I've
> called box() at the end. This all seems very redundant?
>
> Thanks
> Matt
>
>
> --
> mattcstats at gmail.com
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list