简体   繁体   English

R,软件包vcd,mosaic():如何用马赛克图底纹颜色代替图案

[英]R, package vcd, mosaic(): How to substitute mosaic plot shading colours for patterns

Normally the mosaic() function results in a mosaic plot where the shading of the cells represents the Pearson residual for independence. 通常,mosaic()函数会生成一个镶嵌图,其中单元格的阴影表示独立性的Pearson残差。 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? 任何想法如何用mosaic()函数实现这一目标?

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. 红色是另一个不同的图案,红色强度的变化会导致第二个图案的强度发生变化。

Patterns are not easily available in vcd . 模式在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, eg, for using a color version in the electronic paper and a grayscale version in the printed manuscript. 另外,如果使用shading_hcl() ,则可以轻松关闭色度以获得相同颜色的去饱和版本,例如,在电子纸中使用彩色版本,在打印稿件中使用灰度版本。

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

马赛克色

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

马赛克灰

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM