如何在ggplot R中打印相应的汇总词,如mean,max?

时间:2017-07-13 15:00:30

标签: r plot ggplot2

enter image description here

这是我生成此图的代码....

ggplot(dataS, aes(x = property_name, y = val_int,fill=property_name)) +
  geom_boxplot()+ylim(0,4.5)+
  stat_summary(fun.y=mean, colour="darkred", geom="point", shape=18, size=3,show_guide = FALSE) + 
  geom_text(data = means, aes(label =  means$val_int, y = 3.5))+
  geom_text(data = sds, aes(label =  sds$val_int, y =  3.75))+
  geom_text(data = maxs, aes(label =  maxs$val_int, y =  4))+
  geom_text(data = mins, aes(label =  mins$val_int, y =  3.25))+
  theme(axis.text.x = element_text(angle = 25, hjust = 1,vjust=1))

我想把它写下来....最多9816                                sd 1810等等.....我该怎么做?

1 个答案:

答案 0 :(得分:0)

完整答案:

ggplot(dataS, aes(x = property_name, y = val_int,fill=property_name)) +
  geom_boxplot()+ylim(0,4.5)+
  stat_summary(fun.y=mean, colour="darkred", geom="point", shape=18, size=3,show_guide = FALSE) + 
  geom_text(data = means, aes(label =  paste("Mean:", means$val_int), y = 3.5))+
  geom_text(data = sds, aes(label =  paste("SD:", sds$val_int), y =  3.75))+
  geom_text(data = maxs, aes(label =  paste("Max:", maxs$val_int), y =  4))+
  geom_text(data = mins, aes(label =  paste("Min:", mins$val_int), y =  3.25))+
  theme(axis.text.x = element_text(angle = 25, hjust = 1,vjust=1))