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
Hi Hanna, That is because "dotplot" is a lattice graphics function and "legend" is a base graphics function. There are two things you can do to fix this. One is to use the "dotchart" function in base graphics. The other is to use simpleKey in the latticeExtra package for the legend. Jim On Wed, Jun 3, 2015 at 1:06 PM, li li <hannah.hlx at gmail.com> wrote:> 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.
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.
Thank you! It worked. Hanna 2015-06-03 3:49 GMT-04:00, Duncan Mackay <dulcalma at bigpond.com>:> 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. > > ______________________________________________ > 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. >