Anna Zakrisson Braeunlich
2013-Sep-19 10:20 UTC
[R] lattice: double y - problem changing axis color after doubleYScale
Hi, I have had some troubles using doubleYScale. No matter what I try, I cant manage to change the color of the y-axis in the end. I have to produce a black and white plot. There is also something I do not understand regarding fontfamilyj="serif" when using it in: strip=strip.custom() Maybe someone has a better idea for defining which line and dots belong to which y-axis when not using a colorcode than the one I had. I have annotated my questions in the code below. Thank you for your time! Here is some dummy data: Ndata <- data.frame( Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40), sd = rep(c(1, 3, 6), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) Pdata <- data.frame( Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40), sd = rep(c(0.1, 0.2, 0.4), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) SummNdata <- ddply(Ndata, .(Week, fyear, Station), summarise, mean = mean(Ncellpercent), sd = sd(Ncellpercent)) names(Pdata) SummPdata <- ddply(Pdata, .(Week, fyear, Station), summarise, mean = mean(Ppercentcell), sd = sd(Ppercentcell)) library(lattice) library(latticeExtra) library(HH) font.settings <- list( font = 1, cex = 1.2, fontfamily = "serif") my.theme <- list( par.xlab.text = font.settings, par.ylab.text = font.settings, axis.text = font.settings, par.sub=font.settings) plotN <- xyplot(mean ~ Week | Station*fyear, col="black", pch=1, cex=1.1, lty=1, strip = strip.custom(bg = 'white', style=1), # why can I not use fontfamily="serif" here ??? key=list(text=list(c(""), col=c("black")), points=list(pch=1, lty=1, cex=1.5, col=c("black")), columns=1, border=F, x = 0.02, y = 0.55, corner = c(2, 2), title="", cex.title=1.3), ylab = ("Nc"), xlab="Week", data= SummNdata,type="o", par.settings = my.theme) plotN # I would like to add the standard deviations (sd) to the plot. I have tried some stuff, # but for some reason, it does not seem to work. How would I go about this? plotP <- xyplot(mean ~ Week | Station*fyear, col="black", pch=2, cex=1.1, lty=2, strip = strip.custom(bg = 'white', style=1), # why can I not use fontfamily="serif" here ??? key=list(text=list(c(""), col=c("black")), points=list(pch=1, lty=1, cex=1.5, col=c("black")), columns=1, border=F, x = 0.2, y = 0.2, corner = c(2, 2), title="", cex.title=1.3), ylab = ("Pc"), xlab="Week", data= SummPdata,type="o", par.settings = my.theme) plotP doubleYScale(plotN, plotP, add.ylab2 = TRUE) #Why can I not change the axis color by adding to this argument? # I want the y1 and y2 axes to be defined not by color, but by shape and linetype. # I have managed to draw the shapes (defined by Nc and Pc) by the y1 and y2 axes, but I do not manage to get the lines # though the shape - ideas? # Alternative ways that are not based on color (I have to do this black and white). # Is there possible to add shapes to the axis text? such as: # --O-- Nc on the left y-axis (but with lty=1: I could not do a non-dotted line on the keybord). with kind regards Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakrisson@su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b><((((º>`•. . • `•. .• `•. . ><((((º>`•. . • `•. .• `•. .><((((º>`•. . • `•. .• `•. .><((((º>[[alternative HTML version deleted]]
Duncan Mackay
2013-Sep-22 03:00 UTC
[R] lattice: double y - problem changing axis color after doubleYScale
Hi Anna I am not sure what you want but the following should get you part of the way I prefer to keep all my parameters within the function rather than use themes. useOuterStrips(strip = strip.custom(#factor.levels = , par.strip.text list(fontfamily="serif" )), strip.left = strip.custom(#factor.levels = , par.strip.text list(fontfamily="serif" )), xyplot(mean ~ Week | Station*fyear, data= SummPdata, col="black", pch=2, cex=1.1, lty=2, par.settings = list(strip.background = list(col "transparent"), add.text = list(fontfamily = "serif" )), #strip = strip.custom(#factor.levels = , # par.strip.text list(fontfamily="serif" )), scales = list(alternating = c(3,3), fontfamily = "serif"), ylab = list(text = "Pc", fontfamily = "serif"), xlab=list(text = "Week", fontfamily = "serif"), key = list(text = list(labels = c("P","N")), points = list(pch = c(2,20)), lines = list(lty = c(1,2))), type = "o", ylim = c(0,70), subscripts = TRUE, panel = function(x,y, subscripts, ...){ panel.xyplot(x,y, ...) # sd # upper panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y+ SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y- SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) panel.xyplot(x+0.1, SummNdata[subscripts,"mean"], type ="o",pch = 20, lty =1, col = "black") # sd # upper panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"] + SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"]- SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) }# panel )# ) ## useOuterStrips Note that I offset the N data so that the error bars are more legible For sd I just divided them by 2 so you will have to work out what you require Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Anna Zakrisson Braeunlich Sent: Thursday, 19 September 2013 20:21 To: r-help at r-project.org Subject: [R] lattice: double y - problem changing axis color after doubleYScale Hi, I have had some troubles using doubleYScale. No matter what I try, I cant manage to change the color of the y-axis in the end. I have to produce a black and white plot. There is also something I do not understand regarding fontfamilyj="serif" when using it in: strip=strip.custom() Maybe someone has a better idea for defining which line and dots belong to which y-axis when not using a colorcode than the one I had. I have annotated my questions in the code below. Thank you for your time! Here is some dummy data: Ndata <- data.frame( Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40), sd = rep(c(1, 3, 6), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) Pdata <- data.frame( Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40), sd = rep(c(0.1, 0.2, 0.4), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) SummNdata <- ddply(Ndata, .(Week, fyear, Station), summarise, mean = mean(Ncellpercent), sd = sd(Ncellpercent)) names(Pdata) SummPdata <- ddply(Pdata, .(Week, fyear, Station), summarise, mean = mean(Ppercentcell), sd = sd(Ppercentcell)) library(lattice) library(latticeExtra) library(HH) font.settings <- list( font = 1, cex = 1.2, fontfamily = "serif") my.theme <- list( par.xlab.text = font.settings, par.ylab.text = font.settings, axis.text = font.settings, par.sub=font.settings) plotN <- xyplot(mean ~ Week | Station*fyear, col="black", pch=1, cex=1.1, lty=1, strip = strip.custom(bg = 'white', style=1), # why can I not use fontfamily="serif" here ??? key=list(text=list(c(""), col=c("black")), points=list(pch=1, lty=1, cex=1.5, col=c("black")), columns=1, border=F, x = 0.02, y = 0.55, corner = c(2, 2), title="", cex.title=1.3), ylab = ("Nc"), xlab="Week", data= SummNdata,type="o", par.settings = my.theme) plotN # I would like to add the standard deviations (sd) to the plot. I have tried some stuff, # but for some reason, it does not seem to work. How would I go about this? plotP <- xyplot(mean ~ Week | Station*fyear, col="black", pch=2, cex=1.1, lty=2, strip = strip.custom(bg = 'white', style=1), # why can I not use fontfamily="serif" here ??? key=list(text=list(c(""), col=c("black")), points=list(pch=1, lty=1, cex=1.5, col=c("black")), columns=1, border=F, x = 0.2, y = 0.2, corner = c(2, 2), title="", cex.title=1.3), ylab = ("Pc"), xlab="Week", data= SummPdata,type="o", par.settings = my.theme) plotP doubleYScale(plotN, plotP, add.ylab2 = TRUE) #Why can I not change the axis color by adding to this argument? # I want the y1 and y2 axes to be defined not by color, but by shape and linetype. # I have managed to draw the shapes (defined by Nc and Pc) by the y1 and y2 axes, but I do not manage to get the lines # though the shape - ideas? # Alternative ways that are not based on color (I have to do this black and white). # Is there possible to add shapes to the axis text? such as: # --O-- Nc on the left y-axis (but with lty=1: I could not do a non-dotted line on the keybord). with kind regards Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakrisson at su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b><((((:>`. . `. . `. . ><((((:>`. . `. . `. .><((((:>`. . >`. . `. .><((((:>[[alternative HTML version deleted]]
Duncan Mackay
2013-Sep-24 09:32 UTC
[R] lattice: double y - problem changing axis color after doubleYScale
Hi Anna I have never used doubleYScale and I am not sure what you want but try this You need to do this first if columns not correct saves doing later - I forgot to mention it for Week but as you have given the order for the factors do it as well SummPdata[,1] <- as.numeric(SummPdata[,1]) SummNdata[,1] <- as.numeric(SummNdata[,1]) SummPdata[,3] <- factor(SummPdata[,3], levels = c('B1', 'H2', 'H3', 'H4')) SummNdata[,3] <- factor(SummNdata[,3], levels = c('B1', 'H2', 'H3', 'H4')) As the data has a similar structure combine data summData = rbind(SummPdata, SummNdata) summData$element <- rep(c("P","N"), each = 32) Just quickly cut and pasted the colours etc useOuterStrips(strip = strip.custom(#factor.levels = , par.strip.text list(fontfamily="serif" )), strip.left = strip.custom(#factor.levels = , par.strip.text list(fontfamily="serif" )), xyplot(mean ~ Week | Station*interaction(element,fyear), data= summData, cex=1.1, par.settings = list(strip.background = list(col "transparent"), add.text = list(fontfamily = "serif")), #strip = strip.custom(#factor.levels = , # par.strip.text list(fontfamily="serif" )), scales = list(alternating = c(3,3), fontfamily = "serif"), ylab = list(text = "Pc", fontfamily = "serif"), xlab=list(text = "Week", fontfamily = "serif"), key = list(text = list(labels = c("P","N")), points = list(pch = c(2,20), col c("red","blue")), lines = list(lty = c(1,2)), col c("red","blue")), type = "o", ylim = c(0,70), subscripts = TRUE, panel = function(x,y, subscripts, ...){ pnl = panel.number() panel.xyplot(x,y, type = "o", col c("red","blue")[ifelse(pnl <9, 1,2)], lty = c(1,2)[ifelse(pnl <9, 1,2)], pch = c(2,20)[ifelse(pnl <9, 1,2)]) # sd # upper panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y+ summData[subscripts, "sd"]/2, angle = 90, length = 0.04, col = c("red","blue")[ifelse(pnl <9, 1,2)]) # lower panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y- summData[subscripts, "sd"]/2, angle = 90, length = 0.04, col = c("red","blue")[ifelse(pnl <9, 1,2)]) }# panel )# ) ## useOuterStrips You can fill in the LHS strip with a vector of names as required If you want to amend the ylimits see ?combineLimits in the latticeExtra package Duncan -----Original Message----- From: Anna Zakrisson Braeunlich [mailto:anna.zakrisson at su.se] Sent: Tuesday, 24 September 2013 18:28 To: Duncan Mackay Subject: RE: [R] lattice: double y - problem changing axis color after doubleYScale OK, now the code works - thank you. The error bars are added beautifully! As I am using doubleYScale, I am having the problem that the first y-axis is covered by the left hand strip - how can I solve this? I really much prefer using outer.strip() and have one strip vertically on the plot. It saves plot space. I am still having the problem of colourful y-axis when using doubleYScale() - how can I make them black? I have the same problem with the error bars - they are also default colour no matter what I tell them to be. Is there a way around this except Adobe Photoshop? Here is the working script with dummy data (you can just run the lot if you have time). I really appreciate your code - thanks! ...and sorry for being a bit daft and sending a reply before thinking it through properly. Ndata <- data.frame( Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40), sd = rep(c(1, 3, 6), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) Pdata <- data.frame( Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40), sd = rep(c(0.1, 0.2, 0.4), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) SummNdata <- ddply(Ndata, .(Week, fyear, Station), summarise, mean = mean(Ncellpercent), sd = sd(Ncellpercent)) names(Pdata) SummPdata <- ddply(Pdata, .(Week, fyear, Station), summarise, mean = mean(Ppercentcell), sd = sd(Ppercentcell)) SummPdata plotNtest <- useOuterStrips(strip = strip.custom(factor.levels c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), strip.left = strip.custom(factor.levels = c("2007", "2008", "2009"), par.strip.text list(fontfamily="serif" )), xyplot(mean ~ Week | Station*fyear, data= SummNdata, col="black", pch=1, cex=1.1, lty=1, par.settings = list(strip.background = list(col "transparent"), add.text = list(fontfamily "serif" )), strip = strip.custom(factor.levels = c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), scales = list(alternating = c(3,3), fontfamily = "serif"), ylab = list(text = "Nc", fontfamily = "serif"), xlab=list(text = "Week", fontfamily = "serif"), key = list(text = list(labels = c("Pc","Nc")), points = list(pch = c(1,2)), lines = list(lty = c(1,2))), type = "o", ylim = c(0,70), subscripts = TRUE, panel = function(x,y, subscripts, ...){ panel.xyplot(x,y, ...) # sd # upper panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y+ SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y- SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) panel.xyplot(x+0.1, SummNdata[subscripts,"mean"], type ="o",pch = 20, lty =1, col = "black") # sd # upper panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"] + SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"]- SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) }# panel )# ) ## useOuterStrips plotPtest <- useOuterStrips(strip = strip.custom(factor.levels c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), strip.left = strip.custom(factor.levels = c("2007", "2008", "2009"), par.strip.text list(fontfamily="serif" )), xyplot(mean ~ Week | Station*fyear, data= SummPdata, col="black", pch=2, cex=1.1, lty=2, par.settings = list(strip.background list(col "transparent"), add.text = list(fontfamily = "serif" )), strip = strip.custom(factor.levels c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), scales = list(alternating = c(3,3), fontfamily = "serif"), ylab = list(text = "Pc", fontfamily "serif"), xlab=list(text = "Week", fontfamily "serif"), type = "o", ylim = c(0,70), subscripts = TRUE, panel = function(x,y, subscripts, ...){ panel.xyplot(x,y, ...) # sd # upper panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y+ SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y- SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) panel.xyplot(x+0.1, SummPdata[subscripts,"mean"], type ="o",pch = 20, lty =1, col = "black") # sd # upper panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 SummPdata[subscripts,"mean"], y1 = SummPdata[subscripts,"mean"] + SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 SummPdata[subscripts,"mean"], y1 = SummPdata[subscripts,"mean"]- SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) }# panel )# ) ## useOuterStrips plotNtest plotPtest doubleYScale(plotNtest, plotPtest, add.ylab2 = TRUE) Can I make the Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakrisson at su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b><((((?>`?. . ? `?. .? `?. . ><((((?>`?. . ? `?. .? `?. .><((((?>`?. . ? >`?. .? `?. .><((((?>________________________________________ From: Duncan Mackay [dulcalma at bigpond.com] Sent: 22 September 2013 05:00 To: Anna Zakrisson Braeunlich Cc: R Subject: RE: [R] lattice: double y - problem changing axis color after doubleYScale Hi Anna I am not sure what you want but the following should get you part of the way I prefer to keep all my parameters within the function rather than use themes. useOuterStrips(strip = strip.custom(#factor.levels = , par.strip.text list(fontfamily="serif" )), strip.left = strip.custom(#factor.levels = , par.strip.text list(fontfamily="serif" )), xyplot(mean ~ Week | Station*fyear, dataSummPdata, col="black", pch=2, cex=1.1, lty=2, par.settings = list(strip.background = list(col "transparent"), add.text = list(fontfamily = "serif" )), #strip = strip.custom(#factor.levels = , # par.strip.text list(fontfamily="serif" )), scales = list(alternating = c(3,3), fontfamily = "serif"), ylab = list(text = "Pc", fontfamily = "serif"), xlab=list(text = "Week", fontfamily = "serif"), key = list(text = list(labels = c("P","N")), points = list(pch = c(2,20)), lines = list(lty = c(1,2))), type = "o", ylim = c(0,70), subscripts = TRUE, panel = function(x,y, subscripts, ...){ panel.xyplot(x,y, ...) # sd # upper panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y+ SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y- SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) panel.xyplot(x+0.1, SummNdata[subscripts,"mean"], type ="o",pch = 20, lty =1, col = "black") # sd # upper panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"] + SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"]- SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) }# panel )# ) ## useOuterStrips Note that I offset the N data so that the error bars are more legible For sd I just divided them by 2 so you will have to work out what you require Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Anna Zakrisson Braeunlich Sent: Thursday, 19 September 2013 20:21 To: r-help at r-project.org Subject: [R] lattice: double y - problem changing axis color after doubleYScale Hi, I have had some troubles using doubleYScale. No matter what I try, I cant manage to change the color of the y-axis in the end. I have to produce a black and white plot. There is also something I do not understand regarding fontfamilyj="serif" when using it in: strip=strip.custom() Maybe someone has a better idea for defining which line and dots belong to which y-axis when not using a colorcode than the one I had. I have annotated my questions in the code below. Thank you for your time! Here is some dummy data: Ndata <- data.frame( Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40), sd = rep(c(1, 3, 6), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) Pdata <- data.frame( Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40), sd = rep(c(0.1, 0.2, 0.4), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) SummNdata <- ddply(Ndata, .(Week, fyear, Station), summarise, mean = mean(Ncellpercent), sd = sd(Ncellpercent)) names(Pdata) SummPdata <- ddply(Pdata, .(Week, fyear, Station), summarise, mean = mean(Ppercentcell), sd = sd(Ppercentcell)) library(lattice) library(latticeExtra) library(HH) font.settings <- list( font = 1, cex = 1.2, fontfamily = "serif") my.theme <- list( par.xlab.text = font.settings, par.ylab.text = font.settings, axis.text = font.settings, par.sub=font.settings) plotN <- xyplot(mean ~ Week | Station*fyear, col="black", pch=1, cex=1.1, lty=1, strip = strip.custom(bg = 'white', style=1), # why can I not use fontfamily="serif" here ??? key=list(text=list(c(""), col=c("black")), points=list(pch=1, lty=1, cex=1.5, col=c("black")), columns=1, border=F, x = 0.02, y = 0.55, corner = c(2, 2), title="", cex.title=1.3), ylab = ("Nc"), xlab="Week", data= SummNdata,type="o", par.settings = my.theme) plotN # I would like to add the standard deviations (sd) to the plot. I have tried some stuff, # but for some reason, it does not seem to work. How would I go about this? plotP <- xyplot(mean ~ Week | Station*fyear, col="black", pch=2, cex=1.1, lty=2, strip = strip.custom(bg = 'white', style=1), # why can I not use fontfamily="serif" here ??? key=list(text=list(c(""), col=c("black")), points=list(pch=1, lty=1, cex=1.5, col=c("black")), columns=1, border=F, x = 0.2, y = 0.2, corner = c(2, 2), title="", cex.title=1.3), ylab = ("Pc"), xlab="Week", data= SummPdata,type="o", par.settings = my.theme) plotP doubleYScale(plotN, plotP, add.ylab2 = TRUE) #Why can I not change the axis color by adding to this argument? # I want the y1 and y2 axes to be defined not by color, but by shape and linetype. # I have managed to draw the shapes (defined by Nc and Pc) by the y1 and y2 axes, but I do not manage to get the lines # though the shape - ideas? # Alternative ways that are not based on color (I have to do this black and white). # Is there possible to add shapes to the axis text? such as: # --O-- Nc on the left y-axis (but with lty=1: I could not do a non-dotted line on the keybord). with kind regards Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakrisson at su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b><((((:>`?. . ? `?. .? `?. . ><((((:>`?. . ? `?. .? `?. .><((((:>`?. . ? >`?. .? `?. .><((((:>[[alternative HTML version deleted]]
Duncan Mackay
2013-Sep-24 13:38 UTC
[R] lattice: double y - problem changing axis color after doubleYScale
Hi Anna Have a look a ylab in my script - you will need to modify the label I was going from memory on the exact label argument name . I think it is text "Np" or whatever you want. The strip arguments are controlled by useOuterStrip see ?useOuterStrip So you will need to modify as a custom scale there. There is doubleYScale in latticeExtra as well . I do not know or use the HH package As an afterthought you might have a look at ?make.groups for joining datasets Duncan -----Original Message----- From: Anna Zakrisson Braeunlich [mailto:anna.zakrisson at su.se] Sent: Tuesday, 24 September 2013 22:43 To: Duncan Mackay Subject: RE: [R] lattice: double y - problem changing axis color after doubleYScale Thank you! The code works if one removes: strip = strip.custom(factor.levels c("B1", "H2", "H3", "H4")), par.strip.text list(fontfamily="serif" )), it was doubled. It is not quite what I want as I need Nc and Pc in the same plot panel. Just a simple double y-axis plot factorized by station and year and with week on the x-axis. Maybe you know why ylab=() is overridden in the codes you have sent me? ylab=() is defined as normal, but is not showing up in the plot. Am I defining something in the useOuterStrips() command that I am not understanding? I have solved the doubleYScale colour problem: doubleYScale(plotNtest, plotPtest, add.ylab=T, style1=0, style2=0) #makes both axes black. I have a funktioning plot with doubleYScale provided this is solved: 1. I still have the problem that the strip.left =() outer strip is ON TOP of my y-axis. Any ideas on how to tweak the position of the strip and/or move the entire y-axis, but then using doubleYScale (which I know you don't use, but maybe some other person does)? 2. I can add ylab=(). It is non-functional at this time. thank's with kind regards Anna Zakrisson Here is the full code for my doubleYScale plot: Ndata <- data.frame( Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40), sd = rep(c(1, 3, 6), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) Pdata <- data.frame( Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40), sd = rep(c(0.1, 0.2, 0.4), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) SummNdata <- ddply(Ndata, .(Week, fyear, Station), summarise, mean = mean(Ncellpercent), sd = sd(Ncellpercent)) names(Pdata) SummPdata <- ddply(Pdata, .(Week, fyear, Station), summarise, mean = mean(Ppercentcell), sd = sd(Ppercentcell)) SummPdata plotNtest <- useOuterStrips(strip = strip.custom(factor.levels c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), strip.left = strip.custom(factor.levels = c("2007", "2008", "2009"), par.strip.text list(fontfamily="serif" )), xyplot(mean ~ Week | Station*fyear, data= SummNdata, col="black", pch=1, cex=1.1, lty=1, par.settings = list(strip.background = list(col "transparent"), add.text = list(fontfamily "serif" )), strip = strip.custom(factor.levels = c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), scales = list(alternating = c(3,3), fontfamily = "serif"), ylab = list(text = "Nc", fontfamily = "serif"), xlab=list(text = "Week", fontfamily = "serif"), key = list(text = list(labels = c("Pc","Nc")), points = list(pch = c(1,2)), lines = list(lty = c(1,2))), type = "o", ylim = c(0,70), subscripts = TRUE, panel = function(x,y, subscripts, ...){ panel.xyplot(x,y, ...) # sd # upper panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y+ SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y- SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) panel.xyplot(x+0.1, SummNdata[subscripts,"mean"], type ="o",pch = 20, lty =1, col = "black") # sd # upper panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"] + SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"]- SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) }# panel )# ) ## useOuterStrips plotNtest plotPtest <- useOuterStrips(strip = strip.custom(factor.levels c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), strip.left = strip.custom(factor.levels = c("2007", "2008", "2009"), par.strip.text list(fontfamily="serif" )), xyplot(mean ~ Week | Station*fyear, data= SummPdata, col="black", pch=2, cex=1.1, lty=2, par.settings = list(strip.background list(col "transparent"), add.text = list(fontfamily = "serif" )), strip = strip.custom(factor.levels c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), scales = list(alternating = c(3,3), fontfamily = "serif"), ylab = list(text = "Pc", fontfamily "serif"), xlab=list(text = "Week", fontfamily "serif"), type = "o", ylim = c(0,70), subscripts = TRUE, panel = function(x,y, subscripts, ...){ panel.xyplot(x,y, ...) # sd # upper panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y+ SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y- SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) panel.xyplot(x+0.1, SummPdata[subscripts,"mean"], type ="o",pch = 20, lty =1, col = "black") # sd # upper panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 SummPdata[subscripts,"mean"], y1 = SummPdata[subscripts,"mean"] + SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 SummPdata[subscripts,"mean"], y1 = SummPdata[subscripts,"mean"]- SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) }# panel )# ) ## useOuterStrips ?doubleYScale plotNtest plotPtest doubleYScale(plotNtest, plotPtest, add.ylab=T, style1=0, style2=0) Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakrisson at su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b><((((?>`?. . ? `?. .? `?. . ><((((?>`?. . ? `?. .? `?. .><((((?>`?. . ? >`?. .? `?. .><((((?>________________________________________ From: Duncan Mackay [dulcalma at bigpond.com] Sent: 24 September 2013 11:32 To: Anna Zakrisson Braeunlich Cc: R Subject: RE: [R] lattice: double y - problem changing axis color after doubleYScale Hi Anna I have never used doubleYScale and I am not sure what you want but try this You need to do this first if columns not correct saves doing later - I forgot to mention it for Week but as you have given the order for the factors do it as well SummPdata[,1] <- as.numeric(SummPdata[,1]) SummNdata[,1] <- as.numeric(SummNdata[,1]) SummPdata[,3] <- factor(SummPdata[,3], levels c('B1', 'H2', 'H3', 'H4')) SummNdata[,3] <- factor(SummNdata[,3], levels c('B1', 'H2', 'H3', 'H4')) As the data has a similar structure combine data summData = rbind(SummPdata, SummNdata) summData$element <- rep(c("P","N"), each = 32) Just quickly cut and pasted the colours etc useOuterStrips(strip = strip.custom(#factor.levels = , par.strip.text list(fontfamily="serif" )), strip.left = strip.custom(#factor.levels = , par.strip.text list(fontfamily="serif" )), xyplot(mean ~ Week | Station*interaction(element,fyear), data= summData, cex=1.1, par.settings = list(strip.background = list(col "transparent"), add.text = list(fontfamily = "serif")), #strip = strip.custom(#factor.levels = , # par.strip.text list(fontfamily="serif" )), scales = list(alternating = c(3,3), fontfamily = "serif"), ylab = list(text = "Pc", fontfamily = "serif"), xlab=list(text = "Week", fontfamily = "serif"), key = list(text = list(labels = c("P","N")), points = list(pch = c(2,20), col c("red","blue")), lines = list(lty = c(1,2)), col c("red","blue")), type = "o", ylim = c(0,70), subscripts = TRUE, panel = function(x,y, subscripts, ...){ pnl = panel.number() panel.xyplot(x,y, type = "o", col c("red","blue")[ifelse(pnl <9, 1,2)], lty = c(1,2)[ifelse(pnl <9, 1,2)], pch = c(2,20)[ifelse(pnl <9, 1,2)]) # sd # upper panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y+ summData[subscripts, "sd"]/2, angle = 90, length = 0.04, col = c("red","blue")[ifelse(pnl <9, 1,2)]) # lower panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y- summData[subscripts, "sd"]/2, angle = 90, length = 0.04, col = c("red","blue")[ifelse(pnl <9, 1,2)]) }# panel )# ) ## useOuterStrips You can fill in the LHS strip with a vector of names as required If you want to amend the ylimits see ?combineLimits in the latticeExtra package Duncan -----Original Message----- From: Anna Zakrisson Braeunlich [mailto:anna.zakrisson at su.se] Sent: Tuesday, 24 September 2013 18:28 To: Duncan Mackay Subject: RE: [R] lattice: double y - problem changing axis color after doubleYScale OK, now the code works - thank you. The error bars are added beautifully! As I am using doubleYScale, I am having the problem that the first y-axis is covered by the left hand strip - how can I solve this? I really much prefer using outer.strip() and have one strip vertically on the plot. It saves plot space. I am still having the problem of colourful y-axis when using doubleYScale() - how can I make them black? I have the same problem with the error bars - they are also default colour no matter what I tell them to be. Is there a way around this except Adobe Photoshop? Here is the working script with dummy data (you can just run the lot if you have time). I really appreciate your code - thanks! ...and sorry for being a bit daft and sending a reply before thinking it through properly. Ndata <- data.frame( Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40), sd = rep(c(1, 3, 6), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) Pdata <- data.frame( Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40), sd = rep(c(0.1, 0.2, 0.4), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) SummNdata <- ddply(Ndata, .(Week, fyear, Station), summarise, mean = mean(Ncellpercent), sd = sd(Ncellpercent)) names(Pdata) SummPdata <- ddply(Pdata, .(Week, fyear, Station), summarise, mean = mean(Ppercentcell), sd = sd(Ppercentcell)) SummPdata plotNtest <- useOuterStrips(strip = strip.custom(factor.levels c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), strip.left = strip.custom(factor.levels = c("2007", "2008", "2009"), par.strip.text list(fontfamily="serif" )), xyplot(mean ~ Week | Station*fyear, data= SummNdata, col="black", pch=1, cex=1.1, lty=1, par.settings = list(strip.background = list(col "transparent"), add.text = list(fontfamily "serif" )), strip = strip.custom(factor.levels = c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), scales = list(alternating = c(3,3), fontfamily = "serif"), ylab = list(text = "Nc", fontfamily = "serif"), xlab=list(text = "Week", fontfamily = "serif"), key = list(text = list(labels = c("Pc","Nc")), points = list(pch = c(1,2)), lines = list(lty = c(1,2))), type = "o", ylim = c(0,70), subscripts = TRUE, panel = function(x,y, subscripts, ...){ panel.xyplot(x,y, ...) # sd # upper panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y+ SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y- SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) panel.xyplot(x+0.1, SummNdata[subscripts,"mean"], type ="o",pch = 20, lty =1, col = "black") # sd # upper panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"] + SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"]- SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) }# panel )# ) ## useOuterStrips plotPtest <- useOuterStrips(strip = strip.custom(factor.levels c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), strip.left = strip.custom(factor.levels = c("2007", "2008", "2009"), par.strip.text list(fontfamily="serif" )), xyplot(mean ~ Week | Station*fyear, data= SummPdata, col="black", pch=2, cex=1.1, lty=2, par.settings = list(strip.background list(col "transparent"), add.text = list(fontfamily = "serif" )), strip = strip.custom(factor.levels c("B1", "H2", "H3", "H4"), par.strip.text list(fontfamily="serif" )), scales = list(alternating = c(3,3), fontfamily = "serif"), ylab = list(text = "Pc", fontfamily "serif"), xlab=list(text = "Week", fontfamily "serif"), type = "o", ylim = c(0,70), subscripts = TRUE, panel = function(x,y, subscripts, ...){ panel.xyplot(x,y, ...) # sd # upper panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y+ SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y- SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) panel.xyplot(x+0.1, SummPdata[subscripts,"mean"], type ="o",pch = 20, lty =1, col = "black") # sd # upper panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 SummPdata[subscripts,"mean"], y1 = SummPdata[subscripts,"mean"] + SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 SummPdata[subscripts,"mean"], y1 = SummPdata[subscripts,"mean"]- SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) }# panel )# ) ## useOuterStrips plotNtest plotPtest doubleYScale(plotNtest, plotPtest, add.ylab2 = TRUE) Can I make the Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakrisson at su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b><((((?>`?. . ? `?. .? `?. . ><((((?>`?. . ? `?. .? `?. .><((((?>`?. . ? >`?. .? `?. .><((((?>________________________________________ From: Duncan Mackay [dulcalma at bigpond.com] Sent: 22 September 2013 05:00 To: Anna Zakrisson Braeunlich Cc: R Subject: RE: [R] lattice: double y - problem changing axis color after doubleYScale Hi Anna I am not sure what you want but the following should get you part of the way I prefer to keep all my parameters within the function rather than use themes. useOuterStrips(strip = strip.custom(#factor.levels = , par.strip.text list(fontfamily="serif" )), strip.left = strip.custom(#factor.levels = , par.strip.text list(fontfamily="serif" )), xyplot(mean ~ Week | Station*fyear, dataSummPdata, col="black", pch=2, cex=1.1, lty=2, par.settings = list(strip.background = list(col "transparent"), add.text = list(fontfamily = "serif" )), #strip = strip.custom(#factor.levels = , # par.strip.text list(fontfamily="serif" )), scales = list(alternating = c(3,3), fontfamily = "serif"), ylab = list(text = "Pc", fontfamily = "serif"), xlab=list(text = "Week", fontfamily = "serif"), key = list(text = list(labels = c("P","N")), points = list(pch = c(2,20)), lines = list(lty = c(1,2))), type = "o", ylim = c(0,70), subscripts = TRUE, panel = function(x,y, subscripts, ...){ panel.xyplot(x,y, ...) # sd # upper panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y+ SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x, x1 = x, y0 = y, y1 = y- SummPdata[subscripts, "sd"]/2, angle = 90, length = 0.04) panel.xyplot(x+0.1, SummNdata[subscripts,"mean"], type ="o",pch = 20, lty =1, col = "black") # sd # upper panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"] + SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) # lower panel.arrows(x0 = x+0.1, x1 = x+0.1, y0 = SummNdata[subscripts,"mean"], y1 = SummNdata[subscripts,"mean"]- SummNdata[subscripts, "sd"]/2, angle = 90, length = 0.04) }# panel )# ) ## useOuterStrips Note that I offset the N data so that the error bars are more legible For sd I just divided them by 2 so you will have to work out what you require Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Anna Zakrisson Braeunlich Sent: Thursday, 19 September 2013 20:21 To: r-help at r-project.org Subject: [R] lattice: double y - problem changing axis color after doubleYScale Hi, I have had some troubles using doubleYScale. No matter what I try, I cant manage to change the color of the y-axis in the end. I have to produce a black and white plot. There is also something I do not understand regarding fontfamilyj="serif" when using it in: strip=strip.custom() Maybe someone has a better idea for defining which line and dots belong to which y-axis when not using a colorcode than the one I had. I have annotated my questions in the code below. Thank you for your time! Here is some dummy data: Ndata <- data.frame( Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40), sd = rep(c(1, 3, 6), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) Pdata <- data.frame( Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40), sd = rep(c(0.1, 0.2, 0.4), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) SummNdata <- ddply(Ndata, .(Week, fyear, Station), summarise, mean = mean(Ncellpercent), sd = sd(Ncellpercent)) names(Pdata) SummPdata <- ddply(Pdata, .(Week, fyear, Station), summarise, mean = mean(Ppercentcell), sd = sd(Ppercentcell)) library(lattice) library(latticeExtra) library(HH) font.settings <- list( font = 1, cex = 1.2, fontfamily = "serif") my.theme <- list( par.xlab.text = font.settings, par.ylab.text = font.settings, axis.text = font.settings, par.sub=font.settings) plotN <- xyplot(mean ~ Week | Station*fyear, col="black", pch=1, cex=1.1, lty=1, strip = strip.custom(bg = 'white', style=1), # why can I not use fontfamily="serif" here ??? key=list(text=list(c(""), col=c("black")), points=list(pch=1, lty=1, cex=1.5, col=c("black")), columns=1, border=F, x = 0.02, y = 0.55, corner = c(2, 2), title="", cex.title=1.3), ylab = ("Nc"), xlab="Week", data= SummNdata,type="o", par.settings = my.theme) plotN # I would like to add the standard deviations (sd) to the plot. I have tried some stuff, # but for some reason, it does not seem to work. How would I go about this? plotP <- xyplot(mean ~ Week | Station*fyear, col="black", pch=2, cex=1.1, lty=2, strip = strip.custom(bg = 'white', style=1), # why can I not use fontfamily="serif" here ??? key=list(text=list(c(""), col=c("black")), points=list(pch=1, lty=1, cex=1.5, col=c("black")), columns=1, border=F, x = 0.2, y = 0.2, corner = c(2, 2), title="", cex.title=1.3), ylab = ("Pc"), xlab="Week", data= SummPdata,type="o", par.settings = my.theme) plotP doubleYScale(plotN, plotP, add.ylab2 = TRUE) #Why can I not change the axis color by adding to this argument? # I want the y1 and y2 axes to be defined not by color, but by shape and linetype. # I have managed to draw the shapes (defined by Nc and Pc) by the y1 and y2 axes, but I do not manage to get the lines # though the shape - ideas? # Alternative ways that are not based on color (I have to do this black and white). # Is there possible to add shapes to the axis text? such as: # --O-- Nc on the left y-axis (but with lty=1: I could not do a non-dotted line on the keybord). with kind regards Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakrisson at su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b><((((:>`?. . ? `?. .? `?. . ><((((:>`?. . ? `?. .? `?. .><((((:>`?. . ? >`?. .? `?. .><((((:>[[alternative HTML version deleted]]
Reasonably Related Threads
- How to plot 2 continous variables on double y-axis with 2 factors: ggplot2, gplot, lattice, sciplot?
- ggpliot2: reordering of factors in facets facet.grid(). Reordering of factor on x-axis no problem.
- Ggplot2: Moving legend, change fill and removal of space between plots when using grid.arrange() possible use of facet_grid?
- ggplot2: changing strip text in facet_grid and a legend text problem
- plotting smoother function on raw data