Skip to content
Prev 67613 / 398506 Next

barplot usage

On Wed, 2005-04-13 at 19:05 -0300, Antonio Olinto wrote:
You could use something like the following (presuming that your data is
a data frame called 'df'):

  barplot(t(df[2:4]), names.arg = as.character(df$Species))

Note that the row values that you have (excluding the Species name) need
to be rotated 90 degrees as follows:
1 ...
ST1 10 ...
ST2 60 ...
ST3 30 ...

In this case, each column represents the segments of each stacked bar
(or if you set 'beside = TRUE', the individual bars in a group of bars)

Then the labels below each bar in the plot come from the df$Species
column. I used as.character(df$Species) presuming that this column might
be a factor. If not, you can eliminate the use of as.character() here.

HTH,

Marc Schwartz