[R] Key colour problem with lattice plot

Geoff Russell geoffrey.russell at gmail.com
Mon Oct 23 00:25:32 CEST 2006


Many thanks Deepayan,

On 10/23/06, Deepayan Sarkar <deepayan.sarkar at gmail.com> wrote:
> On 10/22/06, Geoff Russell <geoffrey.russell at gmail.com> wrote:
> > Hi,
> >
> > I seem to have a key colour problem with a lattice barchart. The colours on my
> > key rectangle don't match the colours on the barchart.
>
> That's because you are using the wrong colors in the key (see the
> output of show.settings()).

I assumed that the sequence of colors for the bars would match the
sequence for the labels. In any event, when I look at show.settings()
I don't see the cyan color at all. So I tried colors 1 thru 9 without
success.

>
> I would recommend replacing the 'key' argument with something like
> 'auto.key = TRUE'.

Yes, this works except that I need to change the labels from
example$ruminant to just ruminant. So I probably need to use the
key argument explicitly. I have read MASS on trellis, I've read the
barchart help and I can't find any specification of the color sequence choices
in either of these.

I'm happy to read any other documentation, but most things I found
on the net stop short just when the most detail is needed!  C'est
la vie.

Cheers,
Geoff.

>
> -Deepayan
>
> > Here is my data frame:
> >
> > "LandFill" "Ruminants"
> > "United States (USA)" 7777.21428 5528.16
> > "France" 200.527083 1299.87
> > "Australia" 185.878368 2448.17
> > "Russian Federation" 1752.8334 2024.29
> > "Argentina" 283.98732 2567.02
> > "Brazil" 1048.42248 8839.61
> > "Colombia" 265.125 1307.61
> > "Mexico" 981.023351 1814.89
> > "Ethiopia" 9.38020424 1237.49
> > "Sudan" 16.0184936 1796.67
> > "India" 553.425328 12360.3
> > "Pakistan" 47.1593928 2346.71
> > "China" 455.680191 8041.79
> >
> > > example
> >                        LandFill Ruminants
> > United States (USA) 7777.214280   5528.16
> > France               200.527083   1299.87
> > Australia            185.878368   2448.17
> > Russian Federation  1752.833400   2024.29
> > Argentina            283.987320   2567.02
> > Brazil              1048.422480   8839.61
> > Colombia             265.125000   1307.61
> > Mexico               981.023351   1814.89
> > Ethiopia               9.380204   1237.49
> > Sudan                 16.018494   1796.67
> > India                553.425328  12360.30
> > Pakistan              47.159393   2346.71
> > China                455.680191   8041.79
> >
> >
> > And here is my plotting statement.
> >
> > >barchart(rownames(example)~example$LandFill+example$Ruminants,type=c("p","h"),
> > key=list(text=list(c("Landfill","Enteric Fermentation")),
> > rectangles=Rows(trellis.par.get("superpose.symbol"),c(1,2))))))
> >
> >
> >
> > Cheers,
> > Geoff Russell
>



More information about the R-help mailing list