Re: [R] plain shading (not residuals) in mosaic plot

From: Kie Zuraw <kie_at_ucla.edu>
Date: Thu 20 Jul 2006 - 19:45:25 EST

Thank you very much, Gabor Grothendieck and Muhammad Subianto. Both of these work perfectly. I think I was misunderstanding gp and gpar() before. Again, thank you both.

-KZ

Quoting Muhammad Subianto <msubianto@gmail.com>:

> Maybe like this:
> mosaic(allmorph, direction = "v", pop = FALSE,
> gp=gpar(fill=c(grey(0.8),grey(0.4))))
>
> Best, Muhammad Subianto
>
>
> On 7/19/06, Gabor Grothendieck <ggrothendieck@gmail.com> wrote:
>> If you look at ?mosaic the ... argument says it gets passed to strucplot and
>> looking at ?strucplot we see it accepts a gp= arg so try this (same
>> as your plus gp= arg):
>>
>> cols <- c(grey(0.8),grey(0.4))
>> mosaic(allmorph, direction = "v", pop = FALSE, gp = list(col = cols))
>>
>> On 7/19/06, Kie Zuraw <kie@ucla.edu> wrote:
>> > 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",
>> > > "k","b","d","g"),Subst.behavior=c("unsubstituted","substituted")),
>> > > .Names = c("Stem-initial obstruent","Behavior according to
>> > > dictionary")), class = "table")
>> > > mosaic(allmorph,direction="v",pop=FALSE)
>> > > labeling_cells(text=allmorphs,margin=0)(allmorph)
>> >
>> >
>> > 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():
>> >
>> > > mosaicplot(morphs3,color=c(grey(0.8),grey(0.4)))
>> >
>> > ...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:
>> >
>> > > mosaicplot(morphs3,color=c(grey(0.8),grey(0.4)),pop=FALSE)
>> > Warning message:
>> > extra argument(s) 'pop' will be disregarded in:
>> > mosaicplot.default(morphs3, color = c(grey(0.8), grey(0.4)),
>> > > labeling_cells(text=morphs3,margin=0)(morphs3)
>> > 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.
>> >
>> > -Kie Zuraw
>> >
>> > ______________________________________________
>> > R-help@stat.math.ethz.ch mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>> ______________________________________________
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu Jul 20 19:49:24 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 21 Jul 2006 - 00:17:15 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.