- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试注释我使用 ggarrange()
排列的图网格来自 ggpubr
包裹。为此,我使用 annotate_figure()
绘图生成后的函数。
我的问题:当以交互方式执行时(即不使用我的绘图创建文件),它可以完美运行,但是当我导出文件(使用 ggexport()
)时,不会显示注释。
示例:
见 example given in the documentation
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 = 2, nrow = 2)
#> `stat_bindot()` using `bins = 30`. Pick better value with `binwidth`.
annotate_figure(figure,
top = text_grob("Visualizing Tooth Growth", color = "red", face = "bold", size = 14),
bottom = text_grob("Data source: \n ToothGrowth data set", color = "blue",
hjust = 1, x = 1, face = "italic", size = 10),
left = text_grob("Figure arranged using ggpubr", color = "green", rot = 90),
right = "I'm done, thanks :-)!",
fig.lab = "Figure 1", fig.lab.face = "bold"
)
ggexport(figure, "whatever.pdf")
,创建的文件将不包含注释。
最佳答案
您只需要将 annotate_figure(...) 分配给一个变量即可显示或保存,如注释中所述。
这是将变量本身分配回的答案:
figure <- ggarrange(bxp, dp, dens, ncol = 2, nrow = 2)
figure <- annotate_figure(figure,
top = text_grob("Visualizing Tooth Growth", color = "red", face = "bold", size = 14),
bottom = text_grob("Data source: \n ToothGrowth data set", color = "blue",
hjust = 1, x = 1, face = "italic", size = 10),
left = text_grob("Figure arranged using ggpubr", color = "green", rot = 90),
right = "I'm done, thanks :-)!",
fig.lab = "Figure 1", fig.lab.face = "bold"
)
ggsave(filename="figure.png", plot = figure)
ggexport(figure, filename = "figure2.png")
关于r - ggplot/ggpubr : annotate_figure ignored when exporting plot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53066825/
问题总结:当我尝试通过“添加”参数向 ggpubr 图添加汇总统计时,ggpubr 找不到汇总统计函数(下面的示例代码).例如,如果我尝试使用 add="mean_se" 添加错误栏,我会收到一条错误
我不明白为什么底角背景是白色的,而绘图的其余部分是灰色的。无论如何,我可以将底角颜色更改为与绘图其余部分相同的背景吗? 我对每个图使用的代码是: HP_specifikationer_model1
我尝试制作显示 p 值的箱线图 my_comparisons Loading required package: ggplot2 library(tidyverse) ## This works a
我想使用 ggarrange 将 3 个图堆叠为 1 个,但底部图的 x 轴元素(日期)总是消失。 例如,此处缺少 plot_3 (Z) 的轴元素。 ggarrange(plot_1, plot_2,
我有以下代码: ggbarplot(Text1, x = "Page", y = "IA_REGRESSION_OUT_COUNT", color = "Modified", ad
我必须使用 ggarrange 创建这种不同图的排列: arrange <- ggarrange(P1,P2,P3,P4,P5, ncol=3,nrow = 2,common.legend = F,
在许多图中,人们想要突出某些结果之间观察到的差异的统计显着性。可以使用 ggpubr() 或 geom.signif() 扩展在 R 中完成此任务。 我的意思的一个例子在这里(见带有星星的水平条):
我正在尝试使用ggplot2和ggpubr包以星号的形式向我的箱线图添加显着性水平,但我有很多比较,我只想显示重要的。 我尝试在 stat_compare_means 中使用选项 hide.ns=TR
我正在为 ggpubr 中的图例位置而苦苦挣扎。我知道我可以修改图例位置 p.e.通过 ggpar(legend = "bottom")。但是,如何将图例标题放在图例键上方? 在 ggplot2 中,
我正在尝试注释我使用 ggarrange() 排列的图网格来自 ggpubr包裹。为此,我使用 annotate_figure()绘图生成后的函数。 我的问题:当以交互方式执行时(即不使用我的绘图创建
我有一个包含三个箱线图的图,我需要使用 ggplot2 或 ggpubr 显示箱线图对之间的 Spearman 相关性。 很容易绘制类似的图,但具有成对的 p 值。例如, library(ggpubr
如何更改下图中 stat_compare_means 的字体大小?即,更改“Kruskal-Wallis,p = 1.5e-09”和其他 p 值字体大小?我想使用比默认字体更小的字体... 按照数据示
我最近发现很棒 ggpubr包裹。当我与多个小组合作时,我喜欢将我的数据拆分为多个方面 ( facet.by )。 我的问题由与同一张图相关的两个子问题组成。我想要 每组添加唯一的平均水平线 , 和
我想使用 *** 在线性回归中将显着性水平( n.s. 或 ggpubr )显示为标签在 R 中。这似乎是通过使用 aes(label = ..p.signif..) 来完成的如此处发布:https:
我正在尝试修改 stat_regline_equation 的方式在用 ggscatter 绘制的图上显示回归线方程来自 R 包 ggpubr .具体来说,我想显示一致的系数位数,即使某些舍入系数具有
我正在尝试修改 stat_regline_equation 的方式在用 ggscatter 绘制的图上显示回归线方程来自 R 包 ggpubr .具体来说,我想显示一致的系数位数,即使某些舍入系数具有
我是一名优秀的程序员,十分优秀!