Put median value next to the median bar. Pls help, thanks a lot.

I wann to put median value next to the median bar! But don't how to revise the geom_text function. Pls hep. Thanks in advance.

My code is as follows:

 #2. Data Calculation
ISOFF_normalization=ISOFF$Site_Value
ISOFF_pA<-cbind(ISOFF,ISOFF_normalization)
colnames(ISOFF_pA)[22]="Site_Value_Nor"
  #3 Calculate median value
ISOFF_pA$SPLIT<-as.factor(ISOFF_pA$SPLIT)
median<-ISOFF_pA %>% data.frame(ISOFF_pA$SPLIT,ISOFF_pA$Site_Value_Nor)
median.sum <- aggregate(Site_Value_Nor~SPLIT,median,FUN = "median")
median.sum$Site_Value_Nor<-(format(median.sum$Site_Value_Nor,digits = 3,scientific = TRUE))
median.sum$Site_Value_Nor1<-as.numeric(format(median.sum$Site_Value_Nor,digits = 3,scientific = TRUE))


#Isoff
p<-ggplot(ISOFF_pA,aes(x=as.factor(SPLIT),y=Site_Value_Nor)) + #Chart X and Y, Box color type
  geom_boxplot(position=position_dodge(width=0.8)) + 
  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
p+geom_text(data=median.sum, aes(label=(Site_Value_Nor), y = 500 ), 
            size=3,position=position_dodge(width=0.8))

p+geom_text(data=median.sum, aes(label=round(Site_Value_Nor1,2), y = 500 ), 
            size=3,position=position_dodge(width=0.8))

Hi, can you provide a reproducible example. It would make it easier for people to help you.

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.