Anna, You forget to include font.settings <- list( font = 1, cex = 1.3, fontfamily = "serif") in this email, so it wasn't immediately reproducible.
The panel.bwplot.intermediate.hh function explicitly sets the outlier pch to match the median pch. Your controls did affect the cex of the outliers. The col and the pch are overridden by panel.bwplot.intermediate.hh Here is modified function panel.bwplot.intermediate.hh.azb that provides direct access to the new outlier.pch and outlier.col arguments. "panel.bwplot.intermediate.hh.azb" <- function (x, y, horizontal = TRUE, transpose=!horizontal, pch, col, outlier.pch=pch, outlier.col=rep(col, length=length(fac.levels)), at=if (horizontal) levels(as.factor(y)) else levels(as.factor(x)), ## S-Plus only ... ) { ##browser() if (missing(horizontal) && !missing(transpose)) horizontal <- !transpose fac.levels <- if.R(r=if (horizontal) levels(y) else levels(x), s=at) box.par <- list(box.dot=trellis.par.get("box.dot"), box.rectangle=trellis.par.get("box.rectangle"), box.umbrella=trellis.par.get("box.umbrella"), plot.symbol=trellis.par.get("plot.symbol")) tpg <- trellis.par.get("superpose.line") tpg.col <- rep(tpg$col, length=length(fac.levels)) if (!missing(col)) tpg.col <- rep(col, length=length(fac.levels)) for (i in seq(along=fac.levels)) { if (!missing(pch)) { box.par$box.dot$pch <- pch[i] box.par$plot.symbol$pch <- outlier.pch[i] } for (j in names(box.par)) { ##browser() box.par[[j]]$col <- tpg.col[i] box.par$plot.symbol$col <- outlier.col[i] trellis.par.set(j, box.par[[j]]) } if (horizontal) { ii <- as.position(y[y == fac.levels[i]]) xy <- x[y == fac.levels[i]] if.R({ r=panel.bwplot(xy, ii, horizontal=horizontal, ...) },s={ if (is.numeric(at)) { ii <- rep(fac.levels[i], sum(y==i)) xy <- x[y == i] } panel.bwplott(xy, ii, transpose=transpose, ...) }) } else { yx <- y[x == fac.levels[i]] ii <- as.position(x[x == fac.levels[i]]) if.R(r={ panel.bwplot(ii, yx, horizontal=horizontal, ...) },s={ if (is.numeric(at)) { ii <- rep(fac.levels[i], sum(x==i)) yx <- y[x == i] } panel.bwplott(ii, yx, transpose=transpose, ...) }) } } } It probably isn't bulletproof and certainly isn't optimally coded. It works just like panel.bwplot.intermediate.hh with your original bwplot statement. Here is a modified statement to show the changes of the two additional arguments. bwplot(var1 ~ gm, data=mydata, col="black", #box line color panel=panel.bwplot.intermediate.hh.azb, pch=rep(2:4,3), outlier.pch=rep(1,9), outlier.col=rep('red',9), par.settings=list( plot.symbol = list(cex = 1), box.umbrella=list(lty=1), par.xlab.text = font.settings, par.ylab.text = font.settings, axis.text = font.settings, par.sub=font.settings), key=list(text=list(c("factor2a","factor2b", "factor2c"), col="black"), points=list(pch=rep(2:4), cex=1, col="black"), x = .35, y = 1.06, corner = c(2, 2)), #legend position ylab = expression(paste("",delta^{15}, "N")), scales=list(x=list(at=(3*(1:12)-1), labels=c("A", "B", "C")))) Rich On Fri, Aug 23, 2013 at 3:54 AM, Anna Zakrisson Braeunlich < anna.zakris...@su.se> wrote: > OK, I understand. I should probebly have noticed that. > Why can I not control outlier pch=c(...) when using this code? I want all > outliers to be circles and the medians only defined by pch 2-4. > New dummy data with outliers: > > mydata<- data.frame(factor1 = factor(rep(LETTERS[1:3], each = 21)), > #Dummy data > factor2 = factor(rep(c("factor2a", "factor2b", > "factor2c"), > each = 7)), > var1 = rnorm(189, mean = rep(c(0, 3, 17), each = 40), > sd = rep(c(1, 2, 30), each = 20))) > mydata$factor1 <- factor(mydata$factor1, #not necessary for this dataset - > but for me later > levels = c("A", "B", "C"), ordered = TRUE) > library(HH) > > gm <- with(mydata, interaction(factor1, factor2)) > position(gm) <- as.vector(outer(c(-.5,0,.5), (3*(1:3)-1), > "+")) ## help("position", package="HH") > > bwplot(var1 ~ gm, data=mydata, col="black", #box line color > panel=panel.bwplot.intermediate.hh, > pch=rep(2:4,3), > par.settings=list( > plot.symbol = list(cex = 1, col = 1, pch= rep(1:1, 9)), #WHY CAN > I NOT CONTROL OUTLIER pch? > box.umbrella=list(lty=1), > par.xlab.text = font.settings, > par.ylab.text = font.settings, > axis.text = font.settings, > par.sub=font.settings), > key=list(text=list(c("factor2a","factor2b", "factor2c"), > col="black"), > points=list(pch=rep(2:4), cex=1, > col="black"), > x = .35, y = 1.06, corner = c(2, 2)), #legend position > ylab = expression(paste("",delta^{15}, "N")), > scales=list(x=list(at=(3*(1:12)-1), labels=c("A", "B", "C")))) > > > 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.zakris...@su.se > Tel work: +49-(0)3091541281 > Mobile: +49-(0)15777374888 > LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b > > ><((((º>`. . `. . `. . ><((((º>`. . `. . `. .><((((º>`. . > `. . `. .><((((º> > ------------------------------ > *From:* Richard M. Heiberger [r...@temple.edu] > *Sent:* 22 August 2013 23:16 > > *To:* Anna Zakrisson Braeunlich > *Cc:* r-help@r-project.org > *Subject:* Re: [R] lattice: bwplot: getting two plots into one. > > The factor gm has nine levels, therefore you need to use a pch vector > with 9 values > (duplicates are ok). Therefore this will work. > > bwplot(var1 ~ gm, data=mydata, col="black", > pch=rep(1:3,3), ##par.settings=list(box.dot=list(pch=1:3)), > panel=panel.bwplot.intermediate.hh, > key=list(text=list(c("factor2a","factor2b", "factor2c"), > col=c("black")), space="right", > points=list(pch=c(1:3), lty=c(1,3), cex=1, > col=c("black","black"))), > scales=list(x=list(at=(3*(1:12)-1), labels=c("A", "B", > "C"))), > main="my plot") > > > > > > > > On Thu, Aug 22, 2013 at 3:57 AM, Anna Zakrisson Braeunlich < > anna.zakris...@su.se> wrote: > >> Genious! >> Thank's a lot! >> One final question: I am making black and white plots and will have to >> change the pch=c(...) setting. The problem is that every time I change this >> setting I get an error message and have to close RStudio and re-open it for >> anything to work again. I can change the pch=c(...) in the key=list(...) >> without any problem. I get the message: error using package 1: missing >> value where TRUE/FALSE needed. >> I am uncertain what this is referring to. >> Here is my code without the correct pch=c(...) in the plot (but correct >> in the legend): >> >> >> mydata<- data.frame(factor1 = factor(rep(LETTERS[1:3], each = 21)), >> #Dummy data >> factor2 = factor(rep(c("factor2a", "factor2b", >> "factor2c"), >> each = 7)), >> var1 = rnorm(189, mean = rep(c(0, 3, 5), each = 40), >> sd = rep(c(1, 2, 3), each = 20))) >> mydata$factor1 <- factor(mydata$factor1, #not necessary for this >> dataset - but for me later >> levels = c("A", "B", "C"),ordered = TRUE) >> library(HH) >> >> gm <- with(mydata, interaction(factor1, factor2)) >> position(gm) <- as.vector(outer(c(-.0,0,.0), (3*(1:3)-1), >> "+")) ## help("position", package="HH") >> >> bwplot(var1 ~ gm, data=mydata, col="black", # HERE I WOULD LIKE TO SET >> pch=c(1:3), >> panel=panel.bwplot.intermediate.hh, >> key=list(text=list(c("factor2a","factor2b", "factor2c"), >> col=c("black")), space="right", >> points=list(pch=c(1:3), lty=c(1,3), cex=1, >> col=c("black","black"))), >> scales=list(x=list(at=(3*(1:12)-1), labels=c("A", "B", >> "C"))), >> main="my plot") >> >> >> >> >> 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.zakris...@su.se >> Tel work: +49-(0)3091541281 >> Mobile: +49-(0)15777374888 >> LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b >> >> ><((((º>`. . `. . `. . ><((((º>`. . `. . `. .><((((º>`. . >> `. . `. .><((((º> >> ------------------------------ >> *From:* Richard M. Heiberger [r...@temple.edu] >> *Sent:* 21 August 2013 19:54 >> >> *To:* Anna Zakrisson Braeunlich >> *Cc:* r-help@r-project.org >> *Subject:* Re: [R] lattice: bwplot: getting two plots into one. >> >> That is also easy. See the >> >> ## install.packages("HH") ## if you don't yet have it. >> library(HH) >> >> demo("bwplot.examples", package="HH") >> >> These examples show how to use the tools based on >> panel=panel.bwplot.intermediate.hh >> and you will easily be able to modify the code >> for your specific case. >> >> Rich >> >> >> >> On Wed, Aug 21, 2013 at 1:32 PM, Anna Zakrisson Braeunlich < >> anna.zakris...@su.se> wrote: >> >>> Dear Mr. Heiberger, >>> >>> thank you for your reply. I think that you may have misunderstood my >>> question. What I want is to superpose the two panels into one. >>> Lets take this simplified code: >>> bwplot(var1 ~ factor1|factor2, data=mydata, >>> panel=panel.bwplot.intermediate.hh) >>> >>> What I want is this: >>> bwplot(var1 ~ factor1, data=mydata, panel=panel.bwplot.intermediate.hh) >>> But with two factors in the same panel. >>> >>> I know that this will look extremely bad with this dummy data, but I >>> need ito be able to do this with my data. >>> >>> What I also want is to not have any "jitter", but to have them exactly >>> on top of each other - again, this will look terribel on this data, but >>> will be OK for mine. >>> Is this possible in lattice? Maybe using different data frames and make >>> different plots and superpose them on top of each other? Ideas? >>> >>> ggplot2? >>> 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.zakris...@su.se >>> Tel work: +49-(0)3091541281 >>> Mobile: +49-(0)15777374888 >>> LinkedIn: >>> http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b >>> >>> ><((((º>`. . `. . `. . ><((((º>`. . `. . `. .><((((º>`. . >>> `. . `. .><((((º> >>> ------------------------------ >>> *From:* Richard M. Heiberger [r...@temple.edu] >>> *Sent:* 21 August 2013 17:21 >>> *To:* Anna Zakrisson Braeunlich >>> *Cc:* r-help@r-project.org >>> *Subject:* Re: [R] lattice: bwplot: getting two plots into one. >>> >>> This is the fundamentals >>> >>> bwplot(var1 ~ factor1 | factor2, data=mydata, >>> panel=function(...) { >>> panel.abline(h=0, lty=2, col="gray90") >>> panel.bwplot(...) >>> }) >>> >>> You can add the font control if you need to. The major change I made >>> was to put the >>> panel.abline first. It is part of the background and I don't want it to >>> overwrite the graph. >>> Also, I made it in a light gray so it wouldn't take attention away from >>> the data. >>> >>> Rich >>> >>> >>> On Wed, Aug 21, 2013 at 4:42 AM, Anna Zakrisson Braeunlich < >>> anna.zakris...@su.se> wrote: >>> >>>> Dear all, >>>> >>>> I have problems gettting the following as one graph instead of the two >>>> created by this script. I know that with this dummy data, the resulting >>>> graph will look like a catastrophy. I have other data I wish to apply this >>>> too. Just wanted to supply some dummy data to work with. >>>> There may be unnecessary code below. I am still learning. >>>> >>>> Is it possible to do two different bwplots from different dataframes >>>> and then superpose them on to each other? >>>> with kind regards >>>> >>>> A. Zakrisson >>>> >>>> mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)), >>>> #Dummy data >>>> factor2 = factor(rep(c(1:2), each = 16)), >>>> var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40), >>>> sd = rep(c(1, 2, 3), each = 20))) >>>> >>>> font.settings <- list( font = 1, cex = 1.3, fontfamily = "serif") >>>> >>>> my.theme <- list( >>>> box.umbrella = list(col = "black"), #Color of deviation lines (95%) >>>> box.rectangle = list(col="black"), #Color of the line around the box >>>> box.dot = list(col = "black", pch = 3, lty=2, lwd=5, cex=1.3), >>>> plot.symbol = list(cex = 1, col = 1, pch= 0), #outlier size and >>>> color >>>> par.xlab.text = font.settings, >>>> mfrow=c(2,2), >>>> par.ylab.text = font.settings, >>>> axis.line=list(col="black"), #Set "transparent if no axes >>>> axis.text = font.settings, >>>> strip.shingle=list(col=c("white","white")), >>>> superpose.symbol=list(fill=c("white","white")), # boxplots >>>> superpose.fill=list(col=c("white","white")), >>>> superpose.polygon=list(col=c("white","white")), # legend >>>> par.sub=font.settings) >>>> >>>> bgColors <- c("white", "white", "white") >>>> txtColors <- c("black", "black", "black") >>>> myStripStyle <- function(which.panel, factor.levels, par.strip.text, >>>> custBgCol=par.strip.text$custBgCol, >>>> custTxtCol=par.strip.text$custTxtCol,...) { >>>> par.settings = list(layout.heights=list(strip=3)) >>>> panel.rect(0, 0, 1, 1, >>>> col = custBgCol[which.panel], >>>> border = 1.2) >>>> panel.text(x = 0.5, y = 0.5, >>>> font=1, >>>> fontfamily = "serif", >>>> cex=1.4, >>>> lab = factor.levels[which.panel], >>>> col = custTxtCol[which.panel]) >>>> } >>>> >>>> bwplot(var1 ~ factor1|factor2, data = mydata, >>>> groups=factor2, >>>> box.width = 1/3, #width of the boxes >>>> panel=panel.superpose, >>>> ylab = expression(paste("",delta^{15}, "N")), >>>> xlab="Station", >>>> par.settings = my.theme, >>>> par.strip.text=list(custBgCol=bgColors, >>>> custTxtCol=txtColors), >>>> strip=myStripStyle, >>>> scales = list(alternating = TRUE, >>>> x = list(relation = "same", rot=45), >>>> y = list(relation = "same")), >>>> panel.groups = function(x, y, ..., group.number) { >>>> panel.bwplot(x + (group.number-1.8)/3, y, ...) >>>> }) >>>> trellis.focus("panel", 1, 1) >>>> panel.abline(h=0, lty=2) #lwd >>>> trellis.unfocus() >>>> trellis.focus("panel", 2, 1) >>>> panel.abline(h=0, lty=2) #lwd >>>> trellis.unfocus() >>>> >>>> >>>> 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.zakris...@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]] >>>> >>>> >>>> ______________________________________________ >>>> 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. >>>> >>>> >>> >> > [[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.