使用不重叠的马赛克图旋转 y 轴标签

Rotating y axis labels with mosaic plots WITHOUT overlap

此问题与this one极为相似,但从另一个角度来看尚未得到回应。
按照建议的代码,我能够生成马赛克图并旋转标签,以便它们清晰可辨。当(似乎)vcd 包中的 mosaic() 函数无法识别旋转时,问题就出现了,因此它不会调整图形以适应标签,从而产生如下结果:

有什么办法可以改变标签和标题之间的边距吗?如果我是第一个遇到此问题的人,我会感到很惊讶。如果适用,我也愿意使用其他包来获取马赛克图。

代码

aux = structure(c(0L, 0L, 3L, 46L, 107L, 14L, 0L, 0L, 4L, 0L, 0L, 2L, 
9L, 0L, 23L, 2L, 1L, 3L, 14L, 1L, 8L, 26L, 6L, 11L, 6L, 1L, 6L, 
0L, 1L, 1L, 29L, 10L, 62L, 1L, 3L, 1L, 1L, 3L, 1L), .Dim = c(3L, 
13L), .Dimnames = list(abcdefghi = c("Madrid", "Valencia", "Granada"
), jklmnopqr = c("roknbjftxcwl", "mfchldbxuyig", "gtyoxeduijpw", 
"akbcefymvsiw", "ucbfxplietqk", "mzeykauprfdh", "piermgawyjht", 
"chjvatqbylxo", "merhcogjflbd", "wiyrugvmhjlq", "glszdqmjhkov", 
"giowaxrtsknm", "pxucytzvljqw")), class = "table")

library(vcd)
colours = c("brown","darkgreen","darkgrey","orange","darkred","gold","blue","red",
            "white","pink","purple","navy","lightblue","green","peachpuff","violet","yellow","yellow4")
aux_names = names(attr(aux,"dimnames"))
mosaic(aux,main=paste(aux_names,collapse=" vs. "),
       gp=gpar(fill=matrix(sample(colours,max(nrow(aux),ncol(aux))),1,max(nrow(aux),ncol(aux)))),
       pop = FALSE,labeling = labeling_border(rot_labels=c(90,0,0,0),
                                              just_labels=c("left","right")))

这段代码应该可以满足您的需求。

mosaic(aux,main=paste(aux_names,collapse=" vs. "),
       gp=gpar(fill=matrix(sample(colours,max(nrow(aux),ncol(aux))),1,max(nrow(aux),ncol(aux)))),
       pop = FALSE,labeling = labeling_border(rot_labels=c(90,0,0,0),
                                              just_labels=c("left","right"),
                                              offset_varnames = c(8,8,8,8)),
       margins = c(10, 10, 10, 10))