Discussion:
[R] mosaic plot (vcd)
Vanessa Vetter
2013-05-15 17:32:15 UTC
Permalink
Hello everyone,
is there a way to increase the distance between the legend label of the
Pearson residuals and the bar, which shows the color of the residuals, in
the mosaic plot argument (see picture attached)? The minus signs of the
negative scale unfortunately run into the bar. They are therefore difficult
to read.
I would also like to change both, the color of the residuals as well as the
"data driven cut-off points for residuals". But so far I could not combine
the two commands. Is this possible?
# Colorized with HCL default colors and data driven cut-off points for
residuals:
ipol <- function (x) pmin (x / 4, 1)
mosaic (~ herbivory treatment + + + altitude competition, data = erillm1,
shade = TRUE, legend = TRUE, gp_args = list (interpolate = ipol),
labeling_args = list (abbreviate_labs = c (herbivory = TRUE)))
# Colorized with HCL but color matched and default cut-off points for
residuals:
I have now been several papaer to vcd package and strucplot read, but could
find no information on this.

Thank you very much for your help!
greeting
Vanessa Vetter
(Diploma Environmental Sciences, University of Koblenz-Landau)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bildschirmfoto 2013-05-15 um 19.09.36.png
Type: image/png
Size: 16654 bytes
Desc: not available
URL: <Loading Image...>
Achim Zeileis
2013-05-16 07:56:45 UTC
Permalink
Post by Vanessa Vetter
Hello everyone,
is there a way to increase the distance between the legend label of the
Pearson residuals and the bar, which shows the color of the residuals, in
the mosaic plot argument (see picture attached)? The minus signs of the
negative scale unfortunately run into the bar. They are therefore difficult
to read.
I don't think that there is a way to do this directly. A workaround that
can be used to avoid the problem is to specify a "range" and the number of
"ticks" that just leads to fewer digits. For example, for your data you
could set legend_args = list(range = c(-1.9, 1.9), ticks = 5).

For a reproducible example, consider

ipol <- function (x) pmin (x / 4, 1)
mosaic(~ Hair + Eye, data = HairEyeColor,
shade = TRUE, gp_args = list(interpolate = ipol),
legend_args = list(range = c(-7.1, 7.1), ticks = 7))

I have cc'ed David Meyer, the maintainer of vcd. David, for fixing the
problem, I think we should compute 'tw' in legend_resbased() only based on
digits but better on the actual rounded 'at' values. For example, we could
do the following (maybe with digits = 2 rather than 3):

if(is.null(at)) {
at <- seq(from = head(col.bins, 1), to = tail(col.bins, 1), length = ticks)
lab <- format(round(at, digits = digits), nsmall = digits)
}
tw <- lab[which.max(nchar(lab))]
Post by Vanessa Vetter
I would also like to change both, the color of the residuals as well as the
"data driven cut-off points for residuals". But so far I could not combine
the two commands. Is this possible?
# Colorized with HCL default colors and data driven cut-off points for
ipol <- function (x) pmin (x / 4, 1)
mosaic (~ herbivory treatment + + + altitude competition, data = erillm1,
shade = TRUE, legend = TRUE, gp_args = list (interpolate = ipol),
labeling_args = list (abbreviate_labs = c (herbivory = TRUE)))
# Colorized with HCL but color matched and default cut-off points for
I'm not sure what exactly you want to change here, the ipol function above
appears to work as intended.

Hope that helps,
Z
Post by Vanessa Vetter
I have now been several papaer to vcd package and strucplot read, but could
find no information on this.
Thank you very much for your help!
greeting
Vanessa Vetter
(Diploma Environmental Sciences, University of Koblenz-Landau)
Loading...