Dear Carlos Attached is attempt at getting your scales suggestion to work (which at the moment does not) - I'm hoping you have the time to assist again
(data file correctly attached this time). Thanks in advance Mark M On Thu, Sep 15, 2011 at 11:30 PM, Carlos Ortega [via R] < ml-node+s789695n3815937...@n4.nabble.com> wrote: > Hi, > > You can use scales() and parametrize it with a list where you can define > colors, fonts, etc. > > I could not test it on your code because variable "Commodity" is not > present > in the dataset you provided. > > Regards, > Carlos Ortega > www.qualityexcellence.es > > On Thu, Sep 15, 2011 at 11:03 AM, markm0705 <[hidden > email]<http://user/SendEmail.jtp?type=node&node=3815937&i=0>> > wrote: > > > Dear R helpers > > > > I would like to be able to colour code the y-axis labels on a complex dot > > > plot by a variable known as company (of which there are only two). The > > code > > is below and data attached. > > > > Thanks > > > > MarkM > > > > library("lattice") > > library(latticeExtra) # for mergedTrellisLegendGrob() > > > > # set size of the window > > windows(height=10, width=7,rescale=c("fixed")) > > > > ##read the data to a variable > > > > > #---------------------------------------------------------------------------------------- > > > > > Cal_dat <- read.table("Calibration2.dat",header = TRUE,sep = "\t",) > > > > ## set up plotting colours > > > > > #---------------------------------------------------------------------------------------- > > > # Colours for the six commodity > > > > col.pat<-c("violet","cyan","green","red","blue","black","yellow") > > > > # Circles squares and diamond symbols for the year > > sym.pat<-c(19,20,21) > > > > ##set up the plot key > > > > > #---------------------------------------------------------------------------------------- > > > # key for commodities > > # defaults > > bord.col<-"grey90" > > trans.fac<-0.9 > > sym.siz<-1.8 > > > > key1 <- > > draw.key(list(text=list(levels(Cal_dat$Commodity)), > > title="Ore type", > > border =bord.col, > > background = bord.col, > > alpha.background=trans.fac, > > just=1, > > points=list(pch=22, cex=sym.siz, fill=col.pat, > > col="transparent")), > > draw = FALSE) > > key2 <- > > draw.key(list(text=list(levels(factor(Cal_dat$Year))), > > title="Year", > > border = bord.col, > > background = bord.col, > > alpha.background=trans.fac, > > just=1, > > points = list(pch = c(21, 22, 23), cex=sym.siz, > > col="black")), > > draw = FALSE) > > > > mkey <- > > mergedTrellisLegendGrob(list(fun = key2), > > list(fun = key1), > > vertical = FALSE > > ) > > > > ##set some parameters for the plot > > > > > #---------------------------------------------------------------------------------------- > > > trellis.par.set( > > dot.line=list(col = "grey95", lty=1), > > axis.line=list(col = "grey50"), > > axis.text=list(col ="grey50", cex=0.8), > > panel.background=list(col="transparent") > > ) > > > > ## Create the dot plot > > > > > #---------------------------------------------------------------------------------------- > > > # some mean values for reference lines first > > > > ave_dat<-aggregate(Cal_dat$Resc_Gt, by = list(Cal_dat$Year),mean) > > > > # create the plot > > > > with(Cal_dat, > > dotplot(reorder(paste(Mine,Company), Resc_Gt) ~ Resc_Gt, > > fill_var = Commodity, > > pch_var = factor(Year), > > xlab_var = factor(Company), > > pch = c(21, 22, 23), > > cex=sym.siz, > > col = "black", > > fill = col.pat, > > alpha=0.6, > > legend = list(inside = list(fun = mkey,corner = c(0.97, > 0.06))), > > scales = list(x = list(log = 10)), > > xscale.components = xscale.components.log10ticks, > > origin = 0, > > type = c("p","a"), > > main = "Mineral resources", > > xlab= "Total tonnes (billions)", > > panel = function(x, y, ..., subscripts, > > fill, pch, fill_var, pch_var) { > > pch <- pch[pch_var[subscripts]] > > fill <- fill[fill_var[subscripts]] > > panel.ablineq(v=log(ave_dat[1,2]),col="grey60", lty=1, > > > rotate= > > TRUE,label="2002", at=0.40) > > panel.ablineq(v=log(ave_dat[2,2]),col="grey60", lty=1, > > > rotate= > > TRUE,label="2009", at=0.50) > > panel.ablineq(v=log(ave_dat[3,2]),col="grey60", lty=1, > > > rotate= > > TRUE,label="2010", at=0.60) > > panel.dotplot(x, y, pch = pch, fill = fill, ...) > > > > })) > http://r.789695.n4.nabble.com/file/n3815044/Calibration.dat > > Calibration.dat > > > > -- > > View this message in context: > > > http://r.789695.n4.nabble.com/Colour-code-y-axis-labels-on-a-dot-plot-tp3815044p3815044.html > > Sent from the R help mailing list archive at Nabble.com. > > > > ______________________________________________ > > [hidden email] > > <http://user/SendEmail.jtp?type=node&node=3815937&i=1>mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, reproducible code. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] <http://user/SendEmail.jtp?type=node&node=3815937&i=2>mailing > list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://r.789695.n4.nabble.com/Colour-code-y-axis-labels-on-a-dot-plot-tp3815044p3815937.html > To unsubscribe from Colour code y-axis labels on a dot plot, click > here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3815044&code=bWFya20wNzA1QGdtYWlsLmNvbXwzODE1MDQ0fDExNDQyODMxMDM=>. > > -- View this message in context: http://r.789695.n4.nabble.com/Colour-code-y-axis-labels-on-a-dot-plot-tp3815044p3817206.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list 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.