[R] barplot() using beside=TRUE and the density argument
Marc Schwartz
MSchwartz at MedAnalytics.com
Wed Dec 1 14:43:47 CET 2004
On Wed, 2004-12-01 at 10:46 +0000, michael watson (IAH-C) wrote:
> Hi
>
> I am using barplot() to draw some barplots, with a matrix as the data so
> that multiple bars are drawn for each data point. I want to use the
> argument "beside=TRUE" to juxtapose the bars instead of stacking them.
>
> If I execute:
>
> barplot(data,names.arg=names,density=c(20,10),beside=FALSE)
>
> I get the expected behaviour i.e. the bottom part of the column is
> shaded 20 lines per inch, the top part 10 lines per inch. However, if I
> try:
>
> barplot(data,names.arg=names,density=c(20,10),beside=TRUE)
>
> I don't get what *I* would expect (which admittedly might be the wrong
> thing!). What happens is that the left bar for each data point is
> shaded 20 lines per inch, and the right bar is not shaded at all.
>
> Any help would be very much appreciated.
>
> Mick
Without a reproducible example, it is hard to know exactly what you are
seeing.
Running the following example:
barplot(matrix(1:12, ncol = 6), density = c(20, 10), beside = TRUE)
I will admit that the right hand bars in the plot have a shading that is
very light and may be difficult to see on your system, but they are
there.
You might want to try the following:
barplot(matrix(1:12, ncol = 6), density = c(20, 10),
col = c("red", "blue"), beside = TRUE)
to see if the addition of color makes a difference, or if not, try to
increase the second density value.
If this does not help, please provide a reproducible example.
HTH,
Marc Schwartz
More information about the R-help
mailing list