[R] plain shading (not residuals) in mosaic plot
kie at ucla.edu
Wed Jul 19 16:47:32 CEST 2006
Hello. I've been using R for a couple of months and enjoying it a lot.
This is my first post to R-help.
I'm using the vcd package to make mosaic plots with labels on the tiles
indicating the number of items in each cell.
For example, I've made this plot:
> allmorph<-structure(c(10, 26, 17, 100, 70, 97, 253, 430, 185, 177,
> 25, 1), .Dim = as.integer(c(6, 2)), .Dimnames =
> structure(list(Stem.initial.obstruent = c("p", "t,s",
> .Names = c("Stem-initial obstruent","Behavior according to
> dictionary")), class = "table")
So far so good. What I can't figure out how to do--after searching
through the vcd documentation
(http://cran.r-project.org/doc/packages/vcd.pdf), Googling, and
checking the r-help archive--is how to shade the tiles according to
their values for the variables rather than to reflect residuals. That
is, I want all the tiles at the bottom, whose value for the x-axis
variable is "substituted", to be dark grey, and those at the top, in
the "unsubstituted" category, to be light grey.
I know how to do it with mosaicplot():
...but this doesn't work with mosaic(): the command
"mosaic(morphs3,color=c(grey(0.8),grey(0.4)))" yields a plot with all
tiles the same color. And conversely, I can't find a way to use
mosaicplot() and add numeric labels to the tiles--without much hope of
success, I tried combining mosaicplot() with labeling_cells(), but,
unsurprisingly, it didn't work:
extra argument(s) 'pop' will be disregarded in:
mosaicplot.default(morphs3, color = c(grey(0.8), grey(0.4)),
Error in downViewport.vpPath(vpPathDirect(name), strict, recording =
recording) : Viewport 'cell:Stem-initial obstruent=p,Behavior
according to dictionary=unsubstituted' was not found
Does anyone know how to get both the shading I want and the labels I
want, whether with mosaic(), with mosaicplot(), or in some other way?
Thanks for your attention.
More information about the R-help