1

I am using ggline() function from ggpubr to create a line plot with mean and SD. I would like to increase the thickness of my shapes. in ggplot it's usually done through geom_point(stroke=) but it doesn't work with ggline! Does anyone has an idea how to do it?

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)
       )

I would like to have the squares thicker: I would like to have the squares thicker

tjebo
  • 21,977
  • 7
  • 58
  • 94
Amir
  • 15
  • 1
  • 7

1 Answers1

2

You might need to update the geom defaults.. don't really see a way to

First something to keep the defaults, so that you can restore them (from 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

Now for your plot:

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
)

And we restore the default:

update_geom_defaults("point", list(stroke = old$stroke))
# you can also do
#update_geom_defaults("point", list(stroke = 1))
StupidWolf
  • 45,075
  • 17
  • 40
  • 72