我想知道如何将x轴与y轴上的零对齐。我尝试使用ylim(0, 1000)
调整限制,但这似乎不起作用。
library(ggalluvial)
data(vaccinations)
vaccinations <- vaccinations[-c(94),]
levels(vaccinations$response) <- rev(levels(vaccinations$response))
ggplot(vaccinations,
aes(x = survey, stratum = response, alluvium = subject,
y = freq,
fill = response, label = response)) +
scale_x_discrete(expand = c(.1, .1)) +
geom_flow() +
geom_stratum(alpha = .5) +
geom_text(stat = "stratum", size = 3) +
theme(legend.position = "none") +
ggtitle("vaccination survey responses at three points in time")
在这里看到带有蓝色标记的图,标记出我要删除的空间。
答案 0 :(得分:1)
ggplot(vaccinations,
aes(x = survey, stratum = response, alluvium = subject,
y = freq,
fill = response, label = response)) +
scale_x_discrete(expand = c(.1, .1)) +
#adjust the y scale:
scale_y_continuous(expand = c(0, 0), limits = c(0, 1000)) +
geom_flow() +
geom_stratum(alpha = .5) +
geom_text(stat = "stratum", size = 3) +
theme(legend.position = "none") +
ggtitle("vaccination survey responses at three points in time")