0

Normally the mosaic() function results in a mosaic plot where the shading of the cells represents the Pearson residual for independence. Red for negative values, blue for positive values, stronger shade for higher absolute residual values.

I need to substitute the color shading for grayscale patterns in the plot and the legend for publication purposes. The intensity of the grayscale can differentiate the absolute value of the residuals but I must still be able to differentiate between negative and positive residual cells, by using different "texture" patterns in these cells.

Any idea how to implenment this with the mosaic() function?

EDIT: I want to transform the color shades, like in the resulting plot bellow, in grayscale patterns:

#Mosaic Plot Example library(vcd) mosaic(HairEyeColor, shade=TRUE, legend=TRUE)

Mosaic Plot Example

By pattern I mean something like this:

Patterns in a pizza-plot

So that blue is one pattern. Varying intensities of blue result in varying intensities of the same pattern. Red is another different pattern, varying intensities of red result in varying intensities of this second pattern.

Edu
  • 121
  • 5
  • It's easier to help you if your provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data. In general R doesn't really do textured fills. Maybe you could just export the plot as an SVG or PDF and post process it with vector image editing software. – MrFlick Apr 25 '17 at 21:39
  • It's not exactly a texture, just different patterns like dots, stripes, etc. Like in this image https://i.stack.imgur.com/zRwlo.jpg – Edu Apr 25 '17 at 23:31

1 Answers1

1

Patterns are not easily available in vcd. However, you can use different line types for postive and negative residuals, respectively. This works reasonably well (color would be much more prominent, though) and is easily available in different shading functions. Also, if you use shading_hcl() you can easily switch off chroma to obtain desaturated versions of the same colors, e.g., for using a color version in the electronic paper and a grayscale version in the printed manuscript.

mosaic(HairEyeColor, gp = shading_hcl(HairEyeColor, lty = 1:2))

mosaic-color

mosaic(HairEyeColor, gp = shading_hcl(HairEyeColor, lty = 1:2, c = 0))

mosaic-gray

Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49