Re: [R] Key colour problem with lattice plot

From: Alex Brown <alex_at_transitive.com>
Date: Mon 23 Oct 2006 - 09:11:33 GMT

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?

        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)

-Alex Brown

On 22 Oct 2006, at 12:21, Geoff Russell 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.
>
> 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
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon Oct 23 19:14:41 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 23 Oct 2006 - 19:30:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.