Search code examples
rmosaic-plot

Legend instead of label in mosaic( )


I am trying to make a plot that shows three categorical variables. In the experiment, a sound was played (t1-t6), listeners responded (preposition or number), and rated their confidence (1-5). I want to show these three things all together. The best I've come up with is this mosaic plot shown below usingmosaic()`

Mosaic plots with sound, response, and confidence:

Mosaic plots with sound, response, and confidence

However, I can't get this to "look good." One thing that comes to mind is to make the fill (the response) a legend and eliminate the labels, but I can't seem to figure out how to do this.

Any suggestions?

Also, is there any way to change the labels once you've made the plot?

Thank you!


Solution

  • As for the general principles of construction of mosaic plots: It is often a useful guiding principle to start splitting with the "explanatory" variables and then split with respect to the "dependent" variable(s) at the end. Because the later splits are always conditional on earlier ones.

    So in your case, it is pretty obvious that Response should be used after Sound (as you did in your example). It is not quite clear to me whether Confidence should be used as the first split/condition (as you did) or as the last split/condition.

    If I had to verbally describe your plot I would say:

    • In the group of confident persons (Confidence = 5), the first three sounds lead to a preposition response while the other three sounds lead to number responses.

    • In the group of moderately confident persons (Confidence = 4), there is a smooth transition from prepositions to numbers over the Sound from 1 to 6.

    • In the group of persons that are not confident (Confidence = 2 or 3), there is less distinction and the Response is much closer to random guessing.

    If this is a useful interpretation, then the splitting order is ok. Otherwise you might play with the splitting order some more.

    As for the layout. There are many options for labeling in mosaic() and related functions, see vignette("strucplot", package = "vcd"). In this case I would probably use the doubledecker() function (with suitably large margins and a "wide" aspect ratio of the graphics device). That should be easier to read, I guess.

    (I would have demonstrated but couldn't due to the lack of data/reproducible example.)