[R] filled bars with patterns

Paul Murrell p.murrell at auckland.ac.nz
Thu Mar 14 20:59:41 CET 2002


Hi


<snip>
> 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))


This appears to be a bug.  Can you file a bug report for this please?


> 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.


I'm not sure when this might get implemented properly -- in the meantime,
here's a small extension of the example that will "cheat" to give the effect
I think you want ...

 m <- matrix(runif(30), ncol=5)
 barplot(m, beside=FALSE, col=rep(c("white", "light green", "pink"), 2),
         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))
 par(new=TRUE)
 barplot(m, beside=FALSE, col="black", density=-1,
         horiz=TRUE,
         xlim=c(0, 6))


> 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.


There are a number of places in R where several graphics parameters interact
with each other in a nasty way.  Suggestions for clarifications like this
are very welcome.  But even better would be a patch for the barplot code
that implemented the change :)

Paul


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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