You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not about any error, but something that might, potentially, facilitate your work.
I noted that some people asked you "how to add a title to the plot", "how to control this-and-that". I admit, I was searching for this too. Once you answered, that the final graph consists of a set of sub-graphs, combined via cowplot (#85)
There is another package, that might be useful for your (awesome!) work, the patchwork:
BTW, it's possible to add title to the plot via cowplot, but it's not very intuitive:
dp stands for dabestr_plot
title <- ggdraw() +
draw_label(
"My title", fontface = 'bold', x = 0, hjust = 0) +
theme( plot.margin = margin(0, 0, 0, 7)) # the margin aligns title with left edge of the first plot
plot_grid(title, dp,
ncol = 1, rel_heights = c(0.1, 1) #vertical title margins
)
...with patchwork it's easier. Let me use a fake, simple plot to illustrate (just 2 histograms).
p1 <- ggplot(mtcars) + geom_histogram(aes(x=mpg))
p2 <- ggplot(mtcars) + geom_boxplot(aes(y=hp))
p1 + p2+ plot_annotation(title = 'The title', subtitle = 'and subtitle') # 2 plots + common title
But that's not all! You can access each component and modify it after the composition:
compound_graph <- p1 + p2+ plot_annotation(title = 'The title', subtitle = 'and subtitle') # 2 plots + common title
# Let's modify the title of the X axis for the 1st graph:
compound_graph[[1]] <- compound_graph[[1]] + xlab("XXXX")
# also, let's modify the boxplot (just by adding another one, overlying the old one) and change its style:
compound_graph[[2]] <- compound_graph[[2]] + geom_boxplot(aes(y=hp), col="red", fill="blue", alpha=0.5) + theme_bw()
compound_graph
If you want to change the title after all, just do it:
compound_graph + plot_annotation(title = "Naaah, let's change the title :)")
The text was updated successfully, but these errors were encountered:
Dear Author of the dabestr,
It's not about any error, but something that might, potentially, facilitate your work.
I noted that some people asked you "how to add a title to the plot", "how to control this-and-that". I admit, I was searching for this too. Once you answered, that the final graph consists of a set of sub-graphs, combined via cowplot (#85)
There is another package, that might be useful for your (awesome!) work, the patchwork:
BTW, it's possible to add title to the plot via cowplot, but it's not very intuitive:
dp stands for dabestr_plot
...with patchwork it's easier. Let me use a fake, simple plot to illustrate (just 2 histograms).
But that's not all! You can access each component and modify it after the composition:
If you want to change the title after all, just do it:
The text was updated successfully, but these errors were encountered: