答案 0 :(得分:0)
这里有一些代码演示了这个问题。
我希望灰色图表区域的底部边框对齐。
## ------------------------------------------------------------------------
library(tidyverse)
library(ggmosaic)
library(gridExtra)
## ------------------------------------------------------------------------
pruef <- tibble::tribble(
~Geschlecht, ~Studium, ~Test, ~n,
"m", "MINT", "pos", 165L,
"w", "MINT", "pos", 60L,
"m", "HUM", "pos", 30L,
"w", "HUM", "pos", 105L,
"m", "MINT", "neg", 135L,
"w", "MINT", "neg", 40L,
"m", "HUM", "neg", 70L,
"w", "HUM", "neg", 195L
)
## ------------------------------------------------------------------------
pruef %>%
ggplot() +
geom_mosaic(aes(
x = product(Test),
weight = n,
fill = Test
), divider = "vspine") +
guides(fill = guide_legend(reverse = TRUE)) +
labs(x = "", y = "") +
theme(axis.text.x = element_blank(),
axis.ticks.x = element_blank()) -> p1
## ------------------------------------------------------------------------
pruef %>%
ggplot() +
geom_mosaic(aes(x=product(Studium,Geschlecht),weight=n,fill=Test),divider=ddecker()) +
guides(fill=guide_legend(reverse=TRUE)) +
labs(x="",y="") +
theme(axis.ticks.x = element_blank(),
axis.text.x=element_text(angle=90)) ->p2
## ------------------------------------------------------------------------
grid.arrange(p1,p2,nrow=1)
答案 1 :(得分:0)