[R] Re: Universal legend in plot

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri Jan 17 14:02:03 CET 2003


"Vumani Dlamini" <dvumani at hotmail.com> writes:

> Dear R-users:
> 
> I asked a question on how I can have a universal legend in a plot and
> received the following result. I tried using "layout" but I can't seem
> to work on the "empty" plot (where I have to have the legend). I tried
> "oma" but I couldn't improve the quality of the plot, and that I
> didn't know how to specify all the line types using the keyboard,
> infact it is line type 4 (I had _._ and it didn't look nice).
> 
> #
> I am trying to create a graph with 6 panels, but would like to have a
> universal legend as each panel merely denotes a separate stratum. The
> legend has to be at the bottom.
> 
> I use "par(mfrow=c(2,3))" to get the panels, but am not sure how to
> put the legend below the whole graph.
> 
> Thanking you as always

Ah, I think I misunderstood what you wanted there. You want to have a
2x3 layout with 5 plots and one empty, just for legend()?

Could you not just do a blank plot (e.g. plot(0,0, type="n", axes=F,
xlab="", ylab="")) and place the legend onto that?

The lty settings are described in help(par). Beware that legend() can
do you in rather badly if you mix numeric and character
specifications.

        -p

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list