[R] Key colour problem with lattice plot

Deepayan Sarkar deepayan.sarkar at gmail.com
Mon Oct 23 20:53:11 CEST 2006


On 10/23/06, Alex Brown <alex at transitive.com> wrote:
> Hi Geoffrey,
>
>         I replicated your problem, and I came up with the same solution as
> Deepayan, so I won't reprint it here but:
>
>         Can anyone explain why the key is inverted versus the bar order?

Because the key goes from top to bottom, while cartesian coordinates
go from bottom to top. Neither can really be any other way by default,
if you think about it. I did promise someone that I would add an
option to reverse the order in key, but looks like I haven't done that
yet.

>         I'd also like to thank you for showing me a different approach to
> lattice formulae.  I would have used the following formulation:
>
>         ex2 = stack(example)
>         ex3 = cbind(country=rep(rownames(example),2),ex2)
>         barchart(country ~ values, ex3,group=ind, auto.key=TRUE)

Since we are talking about alternatives, here's another:

barchart(as.matrix(example), stack = FALSE, auto.key = TRUE)

-Deepayan

>
> -Alex Brown



More information about the R-help mailing list