wilkelab / cowplot

cowplot: Streamlined Plot Theme and Plot Annotations for ggplot2
https://wilkelab.org/cowplot/
704 stars 84 forks source link

Figure label moves depending on length of text using `draw_figure_label` #136

Closed al-obrien closed 5 years ago

al-obrien commented 5 years ago

I noticed that if my labels are of varying length, the position of the text will translate to the right. This makes the alignment of my figure captions differ between my images. I initially found this issue while using ggpubr but it appears that the function annotate_figure calls the draw_figure_label from cowplot, and is likely the source of what I am experiencing.

For example, adjusting some code from the documentation:

library(cowplot)

p1 <- qplot(1:10, 1:10)
p2 <- qplot(1:10, (1:10)^2)
p3 <- qplot(1:10, (1:10)^3)
p4 <- qplot(1:10, (1:10)^4)

# Create a simple grid
p <- plot_grid(p1, p2, p3, p4, align = 'hv')

p + draw_figure_label(label = "Short Label")

p + draw_figure_label(label = "THIS IS A SUPER SUPER DUPER LONG LABEL LOOK AT ME ……")

image

image

clauswilke commented 5 years ago

Explanation and solution can be found here: https://stackoverflow.com/questions/47724511/longer-plot-labels-move-to-the-right-when-arranging-plots-with-plot-grid-from-co