The col argument to barplot can take a vector or a matrix (the same
dimensions as ww). Try this out:
barplot(ww,beside=T,ylab="Effectif (%)", col= matrix(rep(1:3, each=4),
nrow=4))
Matt Austin
Statistician
Amgen, Inc
800 9AMGEN9 x77431
805-447-7431
"The purpose of computing is insight, not numbers" --Richard Hamming
-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu]On Behalf Of Tristan Lorino
Sent: Thursday, June 08, 2006 2:06 AM
To: s-news@lists.biostat.wustl.edu
Subject: [S] Barplot and colors
Hi,
I have a barplot with 3 groups of 4 bars :
> barplot(ww,beside=T,ylab="Effectif (%)")
where
> ww
BB BBD BBTM
0 0.2757158 0.701565 0.8334865
1 6.6929253 30.936319 6.9957713
2 40.3272231 34.201295 42.0297849
3 52.7041357 34.160820 50.1409573
I would like to have one color per group, something like:
> rep(1:3, rep(4, 3))
[1] 1 1 1 1 2 2 2 2 3 3 3 3
but the option col=rep(1:3, rep(4, 3)) makes all the bars black.
Thank you,
Tristan Lorino
--
Laboratoire Central des Ponts et Chaussées
[Division ESAR ? Section AGR]
Route de Bouaye BP 4129
44341 Bouguenais Cedex
France
Tél 33 (0)2 40 84 56 18
Fax 33 (0)2 40 84 59 92
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|