[R] Multiple plots with one legend

jim holtman jholtman at gmail.com
Sun Mar 27 13:11:14 CEST 2011


Here is how to do the legend:

x <- cbind(rbind(1,2,3), 4)
layout(x, width = c(5,1))
layout.show(4)
plot(1:10, type = 'l')
plot(1:10, type = 'l')
plot(1:10, type = 'l')

# reset margins for creating the legend
oldMar <- par(mar = c(0,0,0,0))
plot.new()
legend('center'
    , legend = 1:10
    , lwd = 3
    , col = 1:10
    )
par(oldMar)


On Sun, Mar 27, 2011 at 12:43 AM, mavkoup <mavkoup at hotmail.com> wrote:
> Yes that's what I had managed to generate too. I can produce my 3 plots. Each
> plot has 10 colored lines say. I want to place the legend in the 4th spot
> listing the name of the 10 colored lines, and their color.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Multiple-plots-with-one-legend-tp3408537p3408850.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?



More information about the R-help mailing list