[R] how to draw a legend outside of the plot

Jim Lemon drjimlemon at gmail.com
Thu Feb 5 09:37:32 CET 2015


Hi Kathryn,
Try this at the end of your example:

plot(y3,type="n",axes=FALSE,xlab="",ylab="")
legend(35,1,c("y1","y2","y3"),pch=1:3)

Jim

On Thu, Feb 5, 2015 at 6:42 PM, Kathryn Lord <kathryn.lord2000 at gmail.com> wrote:
> Dear R users,
>
> I have three plots, so I tried, for exmple,
>
> par(mfrow=c(2,2))
>
> y1 <- rnorm(100)
> y2 <- rnorm(100)
> y3<- rnorm(100)
>
> plot(y1);plot(y2);plot(y3)
>
> Here, I'd like to put a legend on the bottom right hand side (empty space).
>
> is it possible?
>
> Thanks for helping,
>
> Kathryn Lord
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list