ggpubr:更改标签形状笔划

ggpubr: change the label shapes stroke

我正在使用 ggpubr 中的 ggline() 函数创建一个包含均值和 SD 的线图。 我想增加形状的厚度。在 ggplot 中,它通常通过 geom_point(stroke=) 完成,但它不适用于 ggline! 有人知道怎么做吗?

ggline(iris, x = "Species", y = "Sepal.Length", add = "mean_se",
       color = "Species",shape = 7,size = 1,point.size=3,palette = c("black", "blue","red"),width=10,geom_point(stroke=1)
       )

我想让方块更厚:

您可能需要更新 geom 默认值.. 真的找不到办法

首先要保留默认值,以便您可以恢复它们(来自 ggplot: How to set default color for all geoms?):

library(ggplot2)
library(purrr)

geom_aes_defaults <- function() {
  geom_names <- apropos("^Geom", ignore.case = FALSE)
  geoms <- mget(geom_names, env = asNamespace("ggplot2"))
  map(geoms, ~ .$default_aes)
}

old = geom_aes_defaults()$GeomPoint

现在开始你的剧情:

update_geom_defaults("point", list(stroke = 1.5))
ggline(iris, x = "Species", y = "Sepal.Length", add = "mean_se",
       color = "Species",shape = 7,size = 1,point.size=3,
       palette = c("black", "blue","red"),width=10
)

并且我们恢复默认:

update_geom_defaults("point", list(stroke = old$stroke))
# you can also do
#update_geom_defaults("point", list(stroke = 1))