ggmosaic:当因子级别的计数为 0 时如何删除细线

ggmosaic: how to remove the thin line when the count of a factor levels is 0

我一直在尝试使用 ggmosaic 制作马赛克/Marimekko 图,但希望删除 the thin line marking a hspine with the count of 0 (second column)。

这可以在 ggmosaic 中完成吗?我在小插图/帮助文件中找不到如何。下面是一个可重现的例子。

library(ggmosaic)    

happy2 <- happy
happy2$marital <- 
  ifelse(happy2$marital == "never married" & happy2$happy == "not too happy",
       NA, happy2$marital)

ggplot(happy2) + 
  geom_mosaic(aes(x = product(happy, marital), fill = happy))

不知道ggmosaic能不能调整,结果发现这个图用ggplot可以很容易的画出来

happy2 <- happy
happy2$marital <- 
  ifelse(happy2$marital == "never married" & happy2$happy == "not too happy",
       NA, happy2$marital)

ggplot(happy2) + 
  geom_histogram(aes(x = marital, fill = happy), colour = "black", 
               width = 1, stat = "count", position = "fill") +
  scale_y_continuous(expand = c(0,0)) +
  scale_x_discrete(expand = c(0,0))