通常希望最小化图中的墨水.我有一个刻面的情节(facet_wrap),并希望删除尽可能多的墨水,但保持可读性.我已按照我的意愿进行设置,除非在小平面(子图)中不存在x和y轴,除非在最左侧或底部.如此大量的墨水被移除,我相信眼睛需要这些暗示,并且正在询问如何将x和y轴放在a中的所有图中facet_wrap.下面是我的代码到目前为止,当前输出和所需的输出(红线是所需的加入):
library(ggplot); library(grid)
ggplot(mtcars, aes(mpg, hp)) +
geom_point() +
facet_wrap(~carb) +
theme(panel.grid = element_blank(),
panel.background = element_rect(fill = "white", colour = "black"),
panel.border = element_rect(fill = NA, colour = "white"),
axis.line = element_line(),
strip.background = element_blank(),
panel.margin = unit(2, "lines"))
Run Code Online (Sandbox Code Playgroud)
当前情节

期望的情节

我和这个用户有同样的问题:我想制作一个facet_grid带有离散x轴的图,我想让x轴标签写在每个面下,而不是只在底面的一行面下面.例如:
# Drop some factor levels to make the plot smaller
diamondSub <- subset(diamonds, (cut=="Ideal" | cut=="Premium") &
(color=="E" | color=="I"))
# Note that scales="free_x" has no practical effect here
ggplot(diamondSub, aes(x=clarity, y=price)) +
geom_blank()+
geom_boxplot() +
facet_grid(cut~color, scales="free_x")
Run Code Online (Sandbox Code Playgroud)

但是,我不想使用该帖子的解决方案,而只是使用facet_wrap而不是facet_grid,因为我更喜欢facet_grid用条形文本标记条形文本,列的顶部有一个变量,而另一个变量标注行.
当所有x轴实际上相同时,有没有办法在每个面下获得x轴标签facet_grid?