- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为 ggpubr 中的图例位置而苦苦挣扎。我知道我可以修改图例位置 p.e.通过 ggpar(legend = "bottom")
。但是,如何将图例标题放在图例键上方?
在 ggplot2
中,似乎 guide_legend(title.position = "top")
应该这样做,但是如何让它与 ggpubr
? (感谢@c06n 和链接在这里:https://ggplot2.tidyverse.org/reference/guide_legend.html)。我想结合使用
ggplot2
和 ggpubr
但我不知道为什么。
虚拟示例:
df2 <- data.frame(supp=rep(c("VC", "OJ"), each=3),
dose=rep(c("D0.5", "D1", "D2"),2),
len=c(6.8, 15, 33, 4.2, 10, 29.5))
# Plot "len" by "dose" and
# Change line types and point shapes by a second groups: "supp"
p<- ggline(df2, "dose", "len",
linetype = "supp", shape = "supp",
color = "supp", palette = c("#00AFBB", "#E7B800"))
# Seems not working
ggpar(p,
linetype = guide_legend(title = "My title", title.position = "top"))
最佳答案
我不知道 ggpubr
,它似乎是 ggplot2
的包装器。如果这是真的,和/或它实现了与 ggplot2
相同的功能,您应该能够通过 legend guide
实现,参见 here .我认为您需要调整的是 title.position
。
如果您无法使用 ggpubr
实现这一点,我建议您改用 ggplot2
,也许可以根据您的需要调整主题。
编辑。 @markus 有答案,所以把它全部放在一个地方:
p <- ggline(df2, "dose", "len",
linetype = "supp",
shape = "supp",
color = "supp",
palette = c("#00AFBB", "#E7B800")) +
guides(color = guide_legend(title.position = "top",
title.hjust = 0.5))
@Bruno Pinheiro 提出了一个有趣的问题,即为什么只有 color
(和 fill
)有效,而 shape
或 无效线型
。如果情节需要是单色的,这将是相关的。这三个因素作为分组因素应该同样有效。
有没有人有想法?
关于R ggpubr : move legend title above the legend keys,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55090702/
问题总结:当我尝试通过“添加”参数向 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 .具体来说,我想显示一致的系数位数,即使某些舍入系数具有
我是一名优秀的程序员,十分优秀!