How to change the color palette of a mosaic patch

I have the following data and code:

> mat <- matrix(c(120,230,84,70,130,83,13,26,18),3)
> dimnames(mat) <- list(c("good","fair","poor"),c("a","b","c"))
> mat

> mat
       a   b  c
good 120  70 13
fair 230 130 26
poor  84  83 18
> 
> chisq.test(mat)

        Pearson Chi-squared test

data:  mat
X-squared = 11.411, df = 4, p-value = 0.02231

> library(vcd)
> mosaic(mat, shade=T)

enter image description here

The chi-square test shows a significant difference, but the color does not appear, as the residues are small. With higher color residues visible:

enter image description here

? The mosaic shows this information:

highlighting_fill: color vector or palette function used for a highlighted variable, if any.

How to change the fill color for the above chart?

+4
source share
2 answers

vcd 2 4 , , Friendly (1994, Journal of the American Statistics Association, 89, 190-200). , 5% 0,01%, (- ). , - .

: (1) Friendly (1994) , , (, 1 1.8). (2) ( ), , (, 10% 1%), . vcd ?shading_hcl ( mat). Zeileis, Meyer, Hornik (2007). " () ", , 16 (3), 507-525. doi: 10.1198/106186007X237856

(1) :

mosaic(mat, gp = shading_hcl, gp_args = list(interpolate = c(1, 1.8)))

mosaic-hcl (2) :

set.seed(403)
mosaic(mat, gp = shading_max)

mosaic-max

+3

, , gpar

mosaic(mat, shade=T, colorize = T, gp = gpar(fill=matrix(c("red","blue","light green", "green", "black","red","brown","white","blue"), 3, 3)))

- gpar . , . fooobar.com/questions/1077597/...

+1

Source: https://habr.com/ru/post/1584384/


All Articles