Neuls Neuls -3 years ago 152
R Question

Facet labet merging into a single row ggplot2

I have created the following plot using ggplot in R:

enter image description here

the code:

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"))


However, I think the facet_wrap labels look too big and decompensate the overall graphics looking; is there a way to display it in a better looking way? like merging two columns of the df into one? or merging facet labels in a single row?

PD: By the way, using a facet_grid is not an options since X axis from mu and abs are different.

Answer Source

Does this help?

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"))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download