[R] dotplot legend
Duncan Mackay
dulcalma at bigpond.com
Wed Dec 17 23:55:21 CET 2014
If you want to use lattice then the following should give you some tips
Read ?lattice::xyplot
testmatrix<-matrix(c(1,2,3,4,3,6,12,24),nrow=4,ncol=2)
testylabels<-c('w1','x1','y1','z1')
dtf <- data.frame(testmatrix)
dtf
testmatrix
dotplot(X2 ~ X1, dtf)
dtf[,1] = factor(dtf[,1])
dotplot(X2 ~ X1, dtf)
dotplot(X2 ~ X1, dtf, scales=list(x=list(at = paste(1:4),
labels=testylabels)))
see key in xyplot help for the legend
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
rl at openmailbox.org
Sent: Wednesday, 17 December 2014 22:25
To: r-help at r-project.org
Subject: [R] dotplot legend
Subscribers,
For this example:
library(lattice)
testmatrix<-matrix(c(1,2,3,4,3,6,12,24),nrow=4,ncol=2)
testylabels<-c('w1','x1','y1','z1')
dotplot(testmatrix, scales=list(y=list(labels=testylabels), xlab=NULL))
legend('bottomright', 'legend', col=c('blue', 'pink'))
Error in strwidth(legend, units = "user", cex = cex) :
plot.new has not been called yet
The help for 'plot.new' is not understood; the graph has been called in
the previous commands?
______________________________________________
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