[R] Fitting Legend to Matrix Plot

Michael Friendly friendly at yorku.ca
Thu Mar 5 13:55:45 CET 2015


Why not make the legend fit on one line above or below the plot matrix?

?legend
-- look at ncol=, horiz= and xpd= args

On 3/4/2015 4:39 PM, Rich Shepard wrote:
>    I have a matrix plot of ternary diagrams (pdf attached) generated with
> these commands:
>
> opar <- par(xpd=NA,no.readonly=T)
>
> plot(WintersY, pch=as.numeric(WintersX4),
>      col=c("black","red","green","blue","yellow","orange")[WintersX4])
>
> legend(x=0.75, y=0.0, abbreviate(levels(WintersX4),
>      minlength=1),pch=as.numeric(WintersX4),
>      col=c("black","red","green","blue","yellow","orange"), yjust=0)
>
> par(opar)
>
>    I have read ?legend but am uncertain what to adjust so the legend is
> readable yet not overlapping any of the plots. One of this series of plots
> has data from 8 years which would be a worse looking fit.
>
>    How should I specify the legend (or the plots themselves) in a figure
> that
> occupies the full display?
>
> Rich
>
>



More information about the R-help mailing list