[R] Key colour problem with lattice plot

Deepayan Sarkar deepayan.sarkar at gmail.com
Sun Oct 22 21:27:42 CEST 2006


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 would recommend replacing the 'key' argument with something like
'auto.key = TRUE'.

-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