Search code examples
rlabelexponentmosaic-plotvcd

"set_varnames=..." in vcd mosaic plots - how to raise numbers in the labels?


I am looking for a solution on how to raise numbers in the labels of my vcd mosaic plot.

edit: as an example i randomly selected the Sex label in the Titanic dataset:

vnames <- list(set_varnames=c(Sex="Sex=10^X")) 

mosaic(Titanic, labeling_args=vnames)

They always will be displayed as 10^2 and not as 10².

For example working with expression(10^{2}) or

xlab(bquote('Zoospores ('*10^x*') per plastic box'))

in the normal R plots or ggplot2 does not work for the set_varnames= call in labeling_args= in the mosaic()-command of the vcd package.

I could not find an answer to my specific problem in the vcd mosaic plot, only answers regarding labeling in ggplot2 and normal plots..

looking forward to read from you guys !


Solution

  • With the hints of two dedicated members of the statistician community - @Achim Zeileis and David Meyer, i was able to find a rather simple solution.

    To stick with the example:

    vnames <- list(set_varnames=c(Sex="")) 
    
    mosaic(Titanic, labeling_args=vnames)
    
    grid.text(bquote('Sex ('*10^X*') example'), y=0.9, x=0.46,gp=gpar(fontsize=21))
    

    grid.text() did the job. Since you basically add the label afterwards you have to play a little with x and y to get it in place.

    all the best,

    Alexander