Skip to content

color query in mosaic in package vcd

3 messages · Richard M. Heiberger, Achim Zeileis, David Meyer

#
On Fri, 8 Feb 2013, Richard M. Heiberger wrote:

            
No, it's more subtle.

If the dimension of the data (1, 3) is not the same as that of the fill 
(NULL), they are recycled along the last dimension (see Section 3 of 
vignette("strucplot", package = "vcd")). Thus supplying a suitable fill 
matrix works:

mosaic(matrix(1:3, 1, 3),
   gp = gpar(fill=matrix(c("red","gray","blue"), 1, 3)))

David: The reason why Rich's original code does not work properly is that 
the recycling is not triggered properly. In line 160 of strucplot.R we 
check if(length(par) < size) which is not the case here and hence the 
dimension is not added. I think we could do

if (length(par) < size | is.null(dim(par)))
   aperm(array(par, dim = rev(d))) else par

That fixes the problem.

Best,
Z
#
Thanks, fixed upstream.

David
On 2013-02-08 07:20, Achim Zeileis wrote: