[R] filled bars with patterns

Arne Mueller a.mueller at icrf.icnet.uk
Thu Mar 14 03:01:02 CET 2002


Arne Mueller wrote:
> 
> Paul Murrell wrote:
> >
> > Hi
> >
> > > yes, that's sort of what I was looking for. But I've to mix filled bars
> > > with striped bars in a stacked barplot. I could just set the density for
> > > the completely filled bars to something realy high (1000) but it's realy
> > > slow to draw. Is there a way to mix stiped bars and filled pars in the
> > > same plot?
> >
> > There may be a better way, but does the following do the sort of thing you
> > want ...?
> >
> > m <- matrix(runif(30), ncol=5)
> > barplot(m, beside=FALSE, col=rep(c("white", "light green", "pink"), 2),
> >         border=rep(c("white", "red"), 3), horiz=TRUE,
> >         xlim=c(0, 6), axes=FALSE)
> > par(new=TRUE)
> > barplot(m, beside=FALSE, col="blue",
> >         density=rep(c(10, 5, -1), 2),
> >         angle=rep(c(45, -45, 0), 2), horiz=TRUE,
> >         xlim=c(0, 6))
> >
> > Paul

Hi,

I'd also like to have the filled boxes in the legend to be striped. The
legend function has a 'density' attribute, but unfortunately this does't
seem to do anything

following the above example

legend(3.4, 5, c('Axx','Bxx','Cxx','Dxx'), fill = c('red', 'blue',
'green', 'orange'))

is the same as

 legend(3.4, 5, c('Axx','Bxx','Cxx','Dxx'), density=10, fill = c('red',
'blue', 'green', 'orange'),
      density=c(10,-1,20, 200))

In the above example R warns that 'border' is not used yet. Does that
change soon? Basically I'd like the border of each bar to be black
rather than the fill color.

However, isn't it a logic step to implement the density attribute of the
barplot in a way that one can mix filled bars with stiped bars? E.g

barplot(..., besides = FALSE, horiz = TRUE, col = c('red', 'blue',
'green', 'orange'),
	density = c(-1,0,-1,10))

where a density value of 0 means no density AND no filling (empty, just
border), a negative value means complete filling with no stipes and a
positve value means actually stiping with that density valie.

	regards,

	Arne
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list