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?
On 17/12/2014 12:24, rl at openmailbox.org wrote:> 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 yetlattice uses grid graphics, not base graphics. I suspect you have to come to grips with the key parameter in dotplot.> > 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. > > > ----- > No virus found in this message. > Checked by AVG - www.avg.com > Version: 2015.0.5577 / Virus Database: 4253/8751 - Release Date: 12/17/14 > >-- Michael http://www.dewey.myzen.co.uk
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.