Facet标签合并成单行ggplot2

Neu*_*uls 3 r ggplot2 facet-wrap

我在 R 中使用 ggplot 创建了以下图:

在此输入图像描述

代码:

ggplot(hola, aes(.fitted, .resid, color=type)) +
       geom_point() +
       geom_hline(yintercept = 0, color="black") +
       geom_smooth(se = FALSE, color="darkblue")+facet_wrap( type~exp, scales = "free") +
        scale_color_manual(values=c("#5fb772", "#5fabb7"))
Run Code Online (Sandbox Code Playgroud)

然而,我认为facet_wrap标签看起来太大并且破坏了整体图形的外观;有没有办法以更好看的方式显示它?就像将 df 的两列合并为一列?或将面标签合并在一行中?

PD:顺便说一下,使用facet_grid 不是一个选项,因为mu 和abs 的X 轴是不同的。

Lyn*_*akr 9

这有帮助吗?

ggplot(hola, aes(.fitted, .resid, color=type)) +
       geom_point() +
       geom_hline(yintercept = 0, color="black") +
       geom_smooth(se = FALSE, color="darkblue")+
       facet_wrap( type~exp, scales = "free", labeller = label_wrap_gen(multi_line=FALSE)) +
       scale_color_manual(values=c("#5fb772", "#5fabb7"))
Run Code Online (Sandbox Code Playgroud)