[R] Finding different hues for a mosaic plot compatible with grayscale printing

Achim Zeileis Achim.Zeileis at uibk.ac.at
Thu May 13 11:14:43 CEST 2010


On Thu, 13 May 2010, Simon Kiss wrote:

> Dear Colleagues,
> Thanks for that JIm, but It strikes me that printing the residual values in 
> the cells might be a simpler way of communicating the direction of each cell.
> I can get the residuals printed via the labeling_values commands in mosaic, 
> but I cannot seem to *combine* this with labeling_borders commands that I'd 
> like to use to modify the rotation, font size and contents of variable names 
> and labels.
> The following mosaic command draws the plot with the labeling I'd like.
>
>> mosaic(~social_class+ctax_agg_scaled, pop=FALSE, shade=TRUE, main="The 
>> Liberals Carbon Tax Or Green Shift Would Hurt The Canadian Economy By EGP 
>> Class Category", main_gp=gpar(fontsize=16), gp=shading_hcl(CST21$observed, 
>> CST21$expected, ASR21, df=12, h=c(260,0), c=c(100,0), l=c(90,50), 
>> interpolate=c(1,2,3,4)), labeling_args=list(labels=TRUE, 
>> rot_labels=c(25,0,0,25), gp_labels=gpar(fontsize=7), just_labels="center", 
>> offset_labels=c(1,0,0,4), offset_varnames=c(2,0,0,4), 
>> set_varnames=c(ctax_agg_scaled="The Liberal Green Shift Or Carbon Tax Would 
>> Hurt The Canadian Economy", social_class="EGP Class Category")))
>
> And when I take out the labeling_borders commands and insert the following,
>> labeling=labeling_values(value_type=c("residuals"), suppress=0)
>
> then I do get the residuals printed, but the labels are unattractive.
>
> How do I combine labeling_borders and labeling_values commands in one 
> command.

labeling_values() is a combination of labeling_borders() plus 
labeling_cells(). If you want finer control over what happens, I recommend 
to use labeling_borderes() in your mosaic() call and then call 
labeling_cells() manually afterwards. There is an example on how to do 
this in Section 4.2 of the strucplot vignette:
   vignette("strucplot", package = "vcd")

hth,
Z

> Yours, Simon Kiss 
> On 12-May-10, at 2:42 PM, Jim Lemon wrote:
>
>> On 05/12/2010 07:34 PM, Simon Kiss wrote:
>>> I'm working with the following code below to generate a
>>> how do I set the h,c, and l values such that the significant, positive
>>> residuals appear different on a grayscale printer from significant
>>> grayscale residuals. The challenge as I see it is that one can only
>>> distinguish the positive and negative residuals with the hue/. Varying
>>> the chroma and the luminance only affect the distinctions between large
>>> and small and significant and non significant. But my positive and
>>> negative residuals are both large (absolutely) and significant, meaning
>>> that they will have the same chroma and luminosity, but different hues.
>>> I guess the key here is to find two separate hue values that appear
>>> substantially different *on a grayscale printer* at the same chroma and
>>> luminance. I have read through Zeileis et al. (2007, 2008) but can't
>>> quite find the answer there.
>>> I have also tried the Friendly shading to vary the line type, but I
>>> can't find line types that are different enough to communicate the
>>> difference between positive and negative residuals clearly.
>>> 
>>> Your assistance is appreciated.
>>> 
>>>> mosaic(~educ+trade_off_scaled, shade=TRUE, main="Support For
>>> Environmental Protection At The Expense of Creating Jobs By Education",
>>> gp=shading_hcl(CST17$observed, CST17$expected, ASR17, df=6, h=c(260,0),
>>> c=c(100,0), l=c(90,0)), labeling_args=list(rot_labels=c(25,90,0,0),
>>> offset_labels=c(1,0,0,2), offset_varnames=c(2,0,0,4),
>>> set_varnames=c(trade_off_scaled="Protecting The Environment Is More
>>> Important Than Creating Jobs", educ="Level of Education")))
>>> 
>> Hi Simon,
>> I thought that the symbolbox function might do something useful, but it 
>> required a bit of modification. The attached mod allows the user to fill a 
>> rectangle with symbols, which includes things like "+" and "-".
>> 
>> Jim
>> 
>> <symbolbox.R>
>
> *********************************
> Simon J. Kiss, PhD
> SSHRC and DAAD Post-Doctoral Fellow
> John F. Kennedy Institute of North America Studies
> Free University of Berlin
> Lansstraße 7-9
> 14195 Berlin, Germany
> Cell: +49 (0)1525-300-2812,
> Web: http://www.jfki.fu-berlin.de/index.html
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


More information about the R-help mailing list