[R] Fill pattern for Boxplots?

meyfarth at uni-potsdam.de meyfarth at uni-potsdam.de
Fri Aug 10 01:55:17 CEST 2012


Thank you! This sounds good and easy to do (if I can as well make 
stripes to the legend)

--------Original Message----------
From: David L Carlson <dcarlson at tamu.edu>
To: <meyfarth at uni-potsdam.de>, 'John Kane' <jrkrideau at inbox.com>
Date: 09.08.2012 22:10
Subject: Re: [R] Fill pattern for Boxplots?
> It's not too hard to use rect() to add shading to the boxplots. The boxes
> are centered on consecutive integers and the width is +/- .4. The boxplot()
> function returns the quartiles of each box.
>
> set.seed(42)
> DF<- data.frame(val=rnorm(150), grp=rep(letters[1:6], 25))
> outstat<- boxplot(val~grp, DF)           # save the boxplot stats
> ngroups<- length(levels(DF$grp))         # get number of groups
> dval<- c(6, 6, 6, 12, 12, 12)            # density vals for each group
> aval<- c(0, 30, 60, 90, 120, 150)        # angle vals for each group
> rect((1:ngroups)-.4, outstat$stats[2,], (1:ngroups)+.4, outstat$stats[4,],
>       density=dval, angle=aval)            # draw the rectangles
>
> You can also play with lty= and lwd= but that will affect the box border as
> well.
>
> ----------------------------------------------
> David L Carlson
> Associate Professor of Anthropology
> Texas A&M University
> College Station, TX 77843-4352
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
>> project.org] On Behalf Of Susanne Meyfarth
>> Sent: Thursday, August 09, 2012 12:08 PM
>> To: John Kane
>> Cc: r-help at r-project.org
>> Subject: Re: [R] Fill pattern for Boxplots?
>>
>> Thank you. I saw these postings, but I don't want to learn lattice for
>> this reason (was afraid to have to change then everything else in my
>> graph). Anyway, I now tried with different shades of greyscale (4
>> shades). I'm not fully satisfied with it, but it's ok. It's for a
>> publication and depending on whether I have to change the graph, I
>> decide to either put texture in some boxes manually or still look for a
>> solution in R.
>>
>>
>> --------Original Message----------
>> From: John Kane<jrkrideau at inbox.com>
>> To: suse<meyfarth at uni-potsdam.de>, r-help at r-project.org
>> Date: 09.08.2012 16:52
>> Subject: Re: [R] Fill pattern for Boxplots?
>>> Probably not. See http://r.789695.n4.nabble.com/Boxplot-Fill-Pattern-
>> td4457209.html on this topic.
>>> What exactly are you doing?  There may be a workaround or
>> alternative.
>>> John Kane
>>> Kingston ON Canada
>>>
>>>
>> ______________________________________________
>> 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.

-- 
Susanne Meyfarth
Plant Ecology&  Nature Conservation
University of Potsdam
Maulbeerallee 2
D - 14469 Potsdam
Germany

Phone: +49-331-977 1910
Fax: +49-331-977 1930



More information about the R-help mailing list