[R] how to add a vertical line for each panel in a lattice dotplot with log scale?

K. Elo maillists at nic.fi
Thu Jun 7 14:50:26 CEST 2012


Hi!

I recently posted a similar question (entitled "Adding mean line to a 
lattice density plot"). Have not got any usable solution forcing my to 
fall back to the use of the normal 'plot' function. The problem was the 
same as yours: using panel.abline simply did not work, the position of 
the mean line was incorrect. I have posted a workaround (based on plot), 
please see my earlier posting.

HTH,
Kimmo

07.06.2012 15:37, maxbre wrote:
> ...and what if I need to plot another vertical line for showing also the
> means for each panel?
> by simply adding another call to panel.abline () seems not producing a
> correct result for each panel
>
> # medians and means for each panel:
> dotplot(variety ~ yield | site, data = barley,
>         scales=list(x=list(log=TRUE)),
>         layout = c(1,6),
>         panel = function(x,y,...) {
>         panel.dotplot(x,y,...)
>         median.values<- median(x)
>         panel.abline(v=median.values, col.line="red")
>         mean.values<- mean(x)
>         panel.abline(v=mean.values, col.line="red")
> })
>
> In the dataset I'm currently working on (which is not the above mentioned
> example) I've got a wrong plottting of the means for each panel, what I'm
> missing?
>
> thanks



More information about the R-help mailing list