[R] Panel-specific colours in barchart, lattice package --- thanks.

Rolf Turner r.turner at auckland.ac.nz
Thu Jun 12 06:45:36 CEST 2008


On 12/06/2008, at 4:08 PM, Martin Morgan wrote:


> I think this works -- 'custom' variables get sent to the panel
> function, where they're picked up and used for making garish plots.
>
> barchart(y ~ x | f, data=X,
>          mycolors=rainbow(length(levels(X$f))),
>          panel=function(..., mycolors) {
>              col <- mycolors[panel.number()]
>              panel.barchart(..., col=col)
>          })

Yew bewdy!!!  Works like a charm.  Thanks very much.

(I had ***tried*** using panel.number() --- but didn't
get the syntax right, got error messages, and gave up.
Oh me of little faith!)

Thanks also to Gabor Grothendieck who came up with a slightly
less elaborate version of Martin's idea.

	cheers,

		Rolf

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list