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<mailto: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<mailto:anna.zakris...@su.se>
Tel work: +49-(0)3091541281<tel:%2B49-%280%293091541281>
Mobile: +49-(0)15777374888<tel:%2B49-%280%2915777374888>
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

><((((º>`•. . • `•. .• `•. . ><((((º>`•. . • `•. .• `•. .><((((º>`•. . • `•. .• 
>`•. .><((((º>
________________________________
From: Richard M. Heiberger [r...@temple.edu<mailto:r...@temple.edu>]
Sent: 21 August 2013 19:54

To: Anna Zakrisson Braeunlich
Cc: r-help@r-project.org<mailto: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<mailto: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<mailto:anna.zakris...@su.se>
Tel work: +49-(0)3091541281<tel:%2B49-%280%293091541281>
Mobile: +49-(0)15777374888<tel:%2B49-%280%2915777374888>
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

><((((º>`•. . • `•. .• `•. . ><((((º>`•. . • `•. .• `•. .><((((º>`•. . • `•. .• 
>`•. .><((((º>
________________________________
From: Richard M. Heiberger [r...@temple.edu<mailto:r...@temple.edu>]
Sent: 21 August 2013 17:21
To: Anna Zakrisson Braeunlich
Cc: r-help@r-project.org<mailto: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<mailto: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<mailto:anna.zakris...@su.se>
Tel work: +49-(0)3091541281<tel:%2B49-%280%293091541281>
Mobile: +49-(0)15777374888<tel:%2B49-%280%2915777374888>
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

><((((º>`•. . • `•. .• `•. . ><((((º>`•. . • `•. .• `•. .><((((º>`•. . • `•. .• 
>`•. .><((((º>

        [[alternative HTML version deleted]]


______________________________________________
R-help@r-project.org<mailto: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.

Reply via email to