Add mean value number to the chart

Pls help me out!

Wann to add mean value to my chart.

My code is below:

#Isoff
ggplot(ISOFF_pA,aes(x=SPLIT,y=Site_Value_Nor,fill=factor(Slot))) + #Chart X and Y, Box color type
geom_boxplot() + theme_bw() + scale_y_log10(breaks=10^(-1:3)) + coord_cartesian(ylim=c(0.1,1000)) + #scale range set up
theme(axis.text.y=element_text(family="Times",face="bold",colour="#000000",size=14)) + #y axis items font set up
theme(axis.text.x=element_text(angle=90,hjust=1,vjust=1)) + #X axis items location spin and calibration
theme(axis.text.x=element_text(family="Times",face="bold",colour="#000000",size=8.5)) + #x axis items font set up
xlab("SPLIT") + ylab("ED_xCAnoDT_L40-Isoff (pA)") + #x and y title definition
theme(axis.title.y=element_text(family="Times",face="bold",colour="#000000",size=14)) + #y title font set up
theme(axis.title.x=element_text(family="Times",face="bold",colour="#000000",size=14)) + #x title font set up
theme(axis.line=element_line(colour="#000000")) + #picture frame line definition
scale_fill_manual(values=c("#AFAAE0","#FFFAF0","#BFFAF0","#AAAAA0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0","#FFFAF0")) + #box color definition
guides(fill=FALSE) + geom_point() + #add point chart
annotation_logticks() #show log graduation

Thx in advance!!!

Is this the sort of thing you are trying to do? The red point indicates the mean.

library(ggplot2)

DF <- data.frame(SPLIT = rep(c("A", "B", "C"), each = 30),
                 Value = c(rnorm(30, 5, 2), rnorm(30, 150, 30), rnorm(30, 30, 6)))

ggplot(DF, aes(SPLIT, Value)) + geom_boxplot() + scale_y_log10() +
  stat_summary(fun.y = mean, geom = "point", size = 2, color = "red")

Created on 2022-04-22 by the reprex package (v0.2.1)

Thanks a lot, FJCC! I will try your code.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.