Skip to content
Prev 75961 / 398502 Next

Overall Legend

Since I haven't seen a reply to this post, I will attempt one.  Have 
you considered something like the following:

opar <- par(mfrow=c(2,2))

plot(1:2)
lines(2:1, col="blue")
legend("top", legend=c("black", "blue"),
        text.col=c("black", "blue"))
# with a legend on one of the four plots

plot(3:4)
plot(5:6, col="blue")

# Or using mtext to construct a legend in the outer margin
mtext("black", side=3,line=-2, at=.4, outer=TRUE,col="black")
mtext("blue", side=3,line=-2, at=.6, outer=TRUE,col="blue")

par(opar)

##############
RSiteSearch("one legend for multiple plots") identified the following
that discusses placing a single legend with trellis graphics:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/1834.html

	  Also, have you checked Venables and Ripley (2002) Modern Applied 
Statistics with S (Springer)?  I don't have a copy handy, but if my 
memory is correct, they have something relevant to this question.

	  Perhaps someone else will reply with better information than this.
	  spencer graves
Juned Siddique wrote:

            
I want a single horizontal legend to appear at the top of the four plots.
My code is something like this:
lty=c(2,1,3), col=c("green","blue","red"), lwd="2",cex=0.5,inset = 0.05)
the graph because it applies to all four plots. Any help would be
appreciated. Thank you.