[R] How to add legend to a dotplot

Duncan Mackay dulcalma at bigpond.com
Wed Jun 3 09:49:40 CEST 2015


Hi 
If you use the lattice package and not resort to other packages read the ?
xyplot carefully
There are several ways to put a key in the graph including auto.key if you
want something simple ie default
The examples at the bottom give some ideas

If you want something special you can use key = list(...) eg

           key      = list(text = list(labels = LETTERS[1:3],   cex  =
c(1,1,1) ),
                           title = "Farm", cex.title = 1,
                           points = list(pch = c(20,20,3),
                                         col = c("black","grey","grey")),
                           lines = list(lwd = c(2,1,2),
                                        lty = c(1,1,1),
                                        col = c("black","black","grey80")),
                            space = "bottom"),
which gives 3 columns: text points and lines.

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au




-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of li li
Sent: Wednesday, 3 June 2015 13:07
To: r-help
Subject: [R] How to add legend to a dotplot

Hi all,
  I wanted to add the legend to a dotplot using legend funciton. If
does not seem to be working? Anyone have any suggestions?
  Thanks!
  Hanna

______________________________________________
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