[R] ggplot2 / lattice

Felix Andrews felix at nfrac.org
Fri Dec 18 05:01:08 CET 2009


Look at ?panel.bwplot specifically 'fill', 'pch', and 'box.width'.



2009/12/18 Gary Miller <mail2garymiller at gmail.com>:
> @ Gabor: Thanks, it worked.
>
> @ All: Which options I should explore to change the appearance of boxes.
> Like,
>
> 1. Color change.
> 2. Fill-in boxes with colors.
> 3. Change dot to line (used to represent median)
> 4. No gaps between boxplots in each category.
>
> # R Code:
> g <- rep.int(c("A", "B", "C", "D"), 125)
> t <- rnorm(5000)
> a <- sample(t, 500, replace=TRUE)
> b <- sample(t, 500, replace=TRUE)
> dta <- data.frame(val = sample(t,1000), g = gl(4, 250, labels=c("A", "B",
> "C", "D")) , G2 = gl(2,1, labels=c("XX", "YY")))
> library(lattice)
> bwplot(val ~ g | G2, dta)
>
> Thanks,
> Gary
>
> On Thu, Dec 17, 2009 at 10:09 PM, Gabor Grothendieck <
> ggrothendieck at gmail.com> wrote:
>
>> Try this:
>>
>> bwplot(val ~ g | G2, dta)
>>
>>
>> On Thu, Dec 17, 2009 at 9:34 PM, Gary Miller <mail2garymiller at gmail.com>
>> wrote:
>> > Hi R Users,
>> >
>> > Is there a equivalent function for the following R code in Lattice
>> package.
>> > I want to plot a grouped box plots (grouped by two factors).
>> >
>> > g <- rep.int(c("A", "B", "C", "D"), 125)
>> > t <- rnorm(5000)
>> > a <- sample(t, 500, replace=TRUE)
>> > b <- sample(t, 500, replace=TRUE)
>> > dta <- data.frame(val = sample(t,1000), g = gl(4, 250, labels=c("A", "B",
>> > "C", "D")) , G2 = gl(2,1, labels=c("XX", "YY")))
>> > # ggplot2 package required
>> > p <- ggplot(dta, aes(factor(G2), val))
>> > p + geom_boxplot(aes(fill = factor(g)))
>> >
>> > Any suggestion would be highly appreciated!
>> > Gary
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/




More information about the R-help mailing list