[R] mosaicplot: color recycling and defaults of xlab/ylab
Wolfram Fischer
wolfram at fischer-zim.ch
Fri Apr 23 10:15:17 CEST 2004
________________________________________________________________________
PROBLEMS
(a) colors are not recycled over all fields of a mosaicplot.
(b) default xlab/ylab annotation does not always correspond to ``dir''.
________________________________________________________________________
EXAMPLE
par( mfcol = c( 2, 3 ) )
haircolors <- c( 'black', 'brown', 'red', 'sandybrown' )
eyecolors <- c( 'saddlebrown', 'skyblue', 'sandybrown', 'seagreen2' )
mosaicplot( main='(1)', ~Eye + Hair, color=haircolors, data=HairEyeColor)
mosaicplot( main='(2)', ~Hair + Eye, color=eyecolors, data=HairEyeColor)
mosaicplot( main='(3)', ~Eye + Hair, color=rep( each=4, eyecolors), data=HairEyeColor)
mosaicplot( main='(4)', ~Hair + Eye, color=rep( each=4, haircolors ), data=HairEyeColor )
mosaicplot( main='(5)', ~Eye + Hair, color=haircolors, dir=c('h','v'), data=HairEyeColor )
mosaicplot( main='(6)', ~Eye + Hair, color=haircolors, dir=c('h','v'), data=HairEyeColor, xlab='Hair', ylab='Eye' )
________________________________________________________________________
COMMENTS AND QUESTIONS
(1) and (2) are normal mosaicplots with colors of fields
set in correspondance to the colors of hairs resp. of eyes.
(3) is like (1) but I tried to get ``eyecolors''.
Problem (a); what could I do to get ``eyecolors'' in the fields?
(4) is like (2) but the colors should be ``haircolors''.
Same problem as in (3).
(5) is a mirrored version of (1):
I saw: Mirroring does not change the attribution of colors.
If all fields of each line would have the same color
(e.g. the last line should be "green")
I could change ``colors=eyecolors''
and I would receive the graphic I searched.
Here I encountered Problem (b):
In this case, default xlab should be 'Hair' and ylab should be 'Eye'
(6) I solved that problem provisionally by using the xlab and ylab options.
________________________________________________________________________
Thanks - Wolfram
More information about the R-help
mailing list