Reputation: 51
Hi All I am producing this plot with ggline (code below) I was wondering if there is a way to put a line that connect the mean.
ggline(My_table2, x = "Status", y = "Ratio",
color = "Status",
order = c("Non_Treated", "Disease1", "Disease2"), ggtheme=theme_gray(),
ylab = "Ratio", xlab = "Status",
add="mean_se",palette = c("#00AFBB", "#E7B800", "#FC4E07"),
font.label = list(size = 30, face = "bold")) +
theme(text = element_text(size = 10))+theme_bw(base_size = 30)
Upvotes: 0
Views: 523
Reputation: 23747
If you can live with slightly lower level packages - in this case ggplot2 is I think much easier. I think also less code. I am modifying the iris data set because it seems to resemble your data. I am creating a group for the entire data and using this for the line. And quite non-elegantly using stat_summary twice.
library(ggplot2)
iris2 <- iris
iris2$all <- 1
ggplot(iris2, aes(Species, Sepal.Length )) +
stat_summary(aes(color = Species)) +
stat_summary(geom = "line", aes(group = all))
#> No summary function supplied, defaulting to `mean_se()`
#> No summary function supplied, defaulting to `mean_se()`
Created on 2021-04-22 by the reprex package (v2.0.0)
Upvotes: 1