I have a problem with annotate_figure
. Unfortunately the problem does not occure when I prepared my reproducible example. I arranged 5 plots with ggarrange
in one long column and I would like to have a title. However, this title is not centered (add just = "centre"
to the text_grob
command does not help).
When I look at it in the console it is centered so I do not know what I make wrong. Here is the code:
Panelplot_Ring <- ggarrange(R1, R2, R3, R4, R5, ncol=1, nrow=5, common.legend = TRUE, legend="bottom")
Panelplot_Ring <- annotate_figure(Panelplot_Ring, left = text_grob("Ring width [mm]", rot = 90), top = text_grob("Tree-ring width", color = "black", face = "bold", size = 14))
emf("Tree_ring_levels.emf", width = 5/2.54*1.45, height = 20/2.54*1.45, emfPlus=TRUE, emfPlusFont=TRUE, emfPlusRaster =TRUE)
Panelplot_Ring
dev.off()
Here an example code:
data("ToothGrowth")
df <- ToothGrowth
df$dose <- as.factor(df$dose)
# Create some plots
# ::::::::::::::::::::::::::::::::::::::::::::::::::
# Box plot
bxp <- ggboxplot(df, x = "dose", y = "len", color = "dose", palette = "jco")
# Dot plot
dp <- ggdotplot(df, x = "dose", y = "len", color = "dose", palette = "jco")
# Density plot
dens <- ggdensity(df, x = "len", fill = "dose", palette = "jco")
# Arrange and annotate
# ::::::::::::::::::::::::::::::::::::::::::::::::::
figure <- ggarrange(bxp, dp, dens, ncol = 1, nrow = 3, common.legend = TRUE, legend = "bottom")
#> `stat_bindot()` using `bins = 30`. Pick better value with `binwidth`.
figure <- annotate_figure(figure, top = text_grob("Visualizing Tooth Growth", color = "red", face = "bold", size = 14), left = text_grob("Test", color = "green", rot = 90))
emf("Test.emf", width = 5/2.54*1.45, height = 20/2.54*1.45, emfPlus=TRUE, emfPlusFont=TRUE, emfPlusRaster =TRUE)
figure
dev.off()
I can not find the differences in the codes