[R] color of error bars in Dotplot (Hmisc)
ehlers at ucalgary.ca
Wed Jul 27 18:56:46 CEST 2011
On 2011-07-27 05:35, Dieter Menne wrote:
> Irene Prix wrote:
>> In a grouped Dotplot, is there any way to set the color of error bars to
>> be the same as the corresponding symbols?
>> Dotplot(variety~Cbind(yield, yield+2, yield-2)|year, groups=site,
> Customizations of this type can require tricky-digging into the code.
> Dotplot calls panel.dotplot, where you find a line
> plot.line<- trellis.par.get(if (gp) "superpose.line" else "plot.line")
> gp=TRUE when there are groups. So let's give it a try (thanks for the
> self-contained example code)
> # using global assignment here, better use local
> superpose.line = trellis.par.get("superpose.line")
> Dotplot(variety~Cbind(yield, yield+2, yield-2)|year, groups=site,
> The good news: the lines are black. The bad news: they are all black, which
> is the first term. So it looks like these lines are not vectorized (Frank,
> correct me....)
The code for panel.Dotplot contains these two lines:
segmnts(other[,1], y, other[,nc], y, lwd=plot.line$lwd,
If you replace the second line with
then superpose.line can take a vector of colours. But you
have to be careful to match the colour sequence to that used
in the plot symbol. I don't think that this will have any
adverse effect except possibly in any key() assignments.
Here's an example:
Dotplot(variety ~ Cbind(yield, yield+2, yield-2)|year,
groups = site, data = barley, pch = 16, col = 1:6,
par.settings = list(
superpose.line = list(
col = as.numeric(barley$site), lwd = 2)),
panel = mypanel.Dotplot)
where mypanel.Dotplot() is panel.Dotplot() with the modified
line as indicated above.
> You might be able to get customized results with panel.arrow.
> View this message in context: http://r.789695.n4.nabble.com/color-of-error-bars-in-Dotplot-Hmisc-tp3697678p3698327.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help