I'm generating a mosaic plot with vcd::mosaic
. But the text of the factors I was given are very long (cutting them is not an option, and with so many instances, introducing \n
seems daunting), so there's an overlap in the texts, and I haven't been able to force the labels to go perpendicular to the axis.
This is what I'm trying:
a <- data.frame(x=sample(LETTERS[1:4],16,replace = TRUE),
y=rep(paste("very long label here at number", 1:4, paste=" "), 4))
mosaic(y ~ x, data= a, las= 2)
I've also tryed par(las= 2)
and par(las= 3)
but none of those is able to force them into vertical alignment (las= 2
works well with mosaicplot
, though. It's like vcd::mosaic
overrides las
either as a given parameter or as a default-set in par
. I've played also with par(mar)
, but the labels are long enough to fool that workaround.
What can I do to get readable labels?
########## EDIT TO ADD: ##########
I've also tried this, to no avail:
mosaic(y ~ x, data= a, labeling_list= list(gp_text= gpar(las= 2)))
and
mosaic(y ~ x, data= a, labeling_list= list(rot_labels = c(0,90,0,0)))
# Actually placed the "90" in the 4 positions
mosaic(y ~ x, data= a, labeling_list= list(rot_varnames = c(0,90,0,0)))
Finally found it! Key searching docs:
In order to rotate the labels