Reputation: 123
I have created the following plot using ggplot in R:
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.
Upvotes: 3
Views: 2076
Reputation: 8275
ggplot(hola, aes(.fitted, .resid, color=type)) +
geom_point() +
geom_hline(yintercept = 0, color="black") +
geom_smooth(se = FALSE, color="darkblue")+
facet_wrap(paste(type, exp, sep = ":"), scales = "free") +
scale_color_manual(values=c("#5fb772", "#5fabb7"))
This simply makes a new anonymous variable for each level of type
and exp
with values of "abs: exp_F"
, for example. Then there is only one row of labels for each panel.
Upvotes: 2
Reputation: 12074
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"))
Upvotes: 10