ggmosaic plot with asymmetric offset

282 Views Asked by At

I have a mosaic plot generated by ggmosaic:

ggplot(data.frame(a1=c(T,T,F,F), a2=c(T,F,T,F), a3=c(1,3,3,3))) +
  geom_mosaic(aes(weight=a3, x=product(a1,a2), fill=a1))

mosaic plot

I would like to widen the space between the vertical bars without changing the height of the space between the stacked columns:

wide mosaic plot

I've tried using the offset parameter, but it seems to work on both dimensions, and can't isolate just one. An answer using vanilla ggplot is acceptable, but a ggmosaic-only solution is preferred.

1

There are 1 best solutions below

0
On

A less-than-ideal workaround using using geom_bar:

ggplot(data.frame(a1=c(T,T,F,F), a2=c(T,F,T,F), a3=c(1,3,3,3)), aes(width=c(.4,.6,.4,.6)))+
   geom_bar(aes(x=a2, y=-a3, fill=a1), position = "fill", stat = "identity")

bar mosaic