【发布时间】:2021-07-21 07:40:41
【问题描述】:
annotate_figure 有问题。不幸的是,当我准备可重现的示例时,问题并没有发生。我在一长列中安排了 5 个带有ggarrange 的图,我想要一个标题。但是,此标题未居中(将just = "centre" 添加到text_grob 命令没有帮助)。
当我在控制台中查看它时,它是居中的,所以我不知道我做错了什么。 代码如下:
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()
这里是一个示例代码:
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()
我找不到代码中的差异
【问题讨论】:
-
不,我更困惑。当我将其导出为 jpeg 时,一切正常。但在示例代码中,它也适用于 emf。