How to get xlab and ylab to work in mosaic plots in vcd package

1.2k Views Asked by At

For some reason I cannot get xlab and ylab to work in mosaic plots in vcd package.

I tried:

mosaic(~Sex +Survived, 
       data=Titanic,
       shade=T, 
       legend=T, 
       main="myplot", 
       labeling_args=list(abbreviate = c( Sex=2, Survived=1)) ,
       ylab="Gender", 
       xlab="survival")

this labels the axes "Sex" and "Survived" respectively.

mosaic(margin.table(Titanic, c(2,4)),
       ylab="Gender", 
       xlab="survival",
       shade=T, legend=T, 
       main="myplot", 
       labeling_args=list(abbreviate = c( Sex=2, Survived=1)))

this also labels the axes "Sex" and "Survived" respectively.

mosaicplot(margin.table(Titanic, c(2,4)),
           shade=T, 
           legend=T, 
           main="myplot", 
           labeling_args=list(abbreviate = c(Sex=2, Survived=1)), 
           ylab="Gender", 
           xlab="survival")

this labels the axes correctly, but disregards ‘labeling_args’

Does anyone have any suggestions?

1

There are 1 best solutions below

0
On

There is a huge part written on labels in the vcd documentation. What you were looking for is this:

labeling_args = list(set_varnames = c(Sex="Gender", Survived="survival"))

It's been a while since you asked, but maybe it helps someone else ;)

The mosaic function and the mosaicplot function use very different graphic options. So it's no wonder that what works with one doesn't work with the other.