E Hofstadler
2011-May-11 09:11 UTC
[R] Dotplot (package Hmisc) with groups: colours and symbols
Hello all, This question concerns the function Dotplot from the Hmisc package. My aim is to compare values between groups in each panel of the Dotplot, with the values of different groups clearly distinguishable by different symbols. All lines and symbols should be coloured in black. Before adding the panel function to the Dotplot, the groups behaved as desired and were marked by different symbols, but the error bands were blue instead of black. After adding the panel function and changing the trellis colour settings, the error bars are now black, but now the groups are suddenly marked by the same rather than different symbols. I've tried several ways to change the group symbols but to no avail. ## set CI lines to black t1 = trellis.par.get("plot.line") t1$col <- "black" trellis.par.set("plot.line",t1) ## load example data require(lattice) data(barley) ## example plot (problem: groups marked by the same symbol) require(Hmisc) Dotplot(site~Cbind(yield, yield+5, yield-5)|variety, groups=year, data=barley, pch=c(1,2), col="black", panel=function(x,y){ panel.Dotplot(x,y,col="black")}) Key() What am I doing wrong? Many thanks in advance. Esther
Peter Ehlers
2011-May-11 10:52 UTC
[R] Dotplot (package Hmisc) with groups: colours and symbols
On 2011-05-11 02:11, E Hofstadler wrote:> Hello all, > > This question concerns the function Dotplot from the Hmisc package. > > My aim is to compare values between groups in each panel of the > Dotplot, with the values of different groups clearly distinguishable > by different symbols. All lines and symbols should be coloured in > black. > > Before adding the panel function to the Dotplot, the groups behaved as > desired and were marked by different symbols, but the error bands were > blue instead of black. After adding the panel function and changing > the trellis colour settings, the error bars are now black, but now the > groups are suddenly marked by the same rather than different symbols. > I've tried several ways to change the group symbols but to no avail. > > ## set CI lines to black > t1 = trellis.par.get("plot.line") > t1$col<- "black" > trellis.par.set("plot.line",t1) > > ## load example data > require(lattice) > data(barley) > > ## example plot (problem: groups marked by the same symbol) > > require(Hmisc) > Dotplot(site~Cbind(yield, yield+5, yield-5)|variety, groups=year, > data=barley, pch=c(1,2), col="black", > panel=function(x,y){ > panel.Dotplot(x,y,col="black")}) > Key() > > > > > What am I doing wrong?It seems to me that 'plot.line' is the wrong lattice parameter to set. Try this: Dotplot(site~Cbind(yield, yield+5, yield-5)|variety, groups=year, par.settings=list(superpose.line=list(col="black")), data=barley, pch=c(1,2), col="black") No need to specify the panel function. (To see what's wrong with the panel function, add '...' to the arguments.) Peter Ehlers> > Many thanks in advance. > Esther > > ______________________________________________ > R-help at 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.
Hugo Mildenberger
2011-May-11 13:47 UTC
[R] Dotplot (package Hmisc) with groups: colours and symbols
Hello Esther, you left out the ellipsis argument (...) to the panel function. That argument serves a placeholder for the rest of the parameters you did not want to name and pass explicitely. If you don't pass the ellipsis to panel.Dotplot, all unnamed parameters will get default values. You can see these defaults by typing panel.dotplot or edit(panel.dotplot) on the command line. Dotplot( site~Cbind(yield, yield+5, yield-5)|variety, groups = year, data = barley, pch = c(1,2), panel = function(x,y,...){ panel.Dotplot(x,y,col="black",...); }) Best On Wednesday 11 May 2011 11:11:50 E Hofstadler wrote:> Hello all, > > This question concerns the function Dotplot from the Hmisc package. > > My aim is to compare values between groups in each panel of the > Dotplot, with the values of different groups clearly distinguishable > by different symbols. All lines and symbols should be coloured in > black. > > Before adding the panel function to the Dotplot, the groups behaved as > desired and were marked by different symbols, but the error bands were > blue instead of black. After adding the panel function and changing > the trellis colour settings, the error bars are now black, but now the > groups are suddenly marked by the same rather than different symbols. > I've tried several ways to change the group symbols but to no avail. > > ## set CI lines to black > t1 = trellis.par.get("plot.line") > t1$col <- "black" > trellis.par.set("plot.line",t1) > > ## load example data > require(lattice) > data(barley) > > ## example plot (problem: groups marked by the same symbol) > > require(Hmisc) > Dotplot(site~Cbind(yield, yield+5, yield-5)|variety, groups=year, > data=barley, pch=c(1,2), col="black", > panel=function(x,y){ > panel.Dotplot(x,y,col="black")}) > Key() > > > > > What am I doing wrong? > > Many thanks in advance. > Esther > > ______________________________________________ > R-help at 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. >
Apparently Analagous Threads
- color of error bars in Dotplot (Hmisc)
- how to add a vertical line for each panel in a lattice dotplot with log scale?
- [FORGED] Extracting specified pages from a lattice ("trellis") object.
- dotplot (lattice) with panel.segments and groups
- [FORGED] Extracting specified pages from a lattice ("trellis") object.