how to draw a legend outside of the plot

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to draw a legend outside of the plot

Kathie
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: how to draw a legend outside of the plot

Jim Lemon-4
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 <[hidden email]> 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]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.