0
votes

I have made a ggplot of the insulin conc. at different timepoints (OGTT) for two different treatments. Afterwards I have added points showing the mean values:

p<-ggplot(data=data2, aes(x = factor(OGTT), y = Insulin, group = StudyID, color=StudyID)) + 
  geom_line() +
  facet_grid(End.start ~Treatment)+ 
  stat_summary(aes(group = Treatment), geom = "point", fun.y = mean, shape = 16, size = 2) 

My questions are:

  1. How can I add errorbars to the mean value points?
  2. How can I avoid that the plot shows any legends?
1

1 Answers

1
votes

The ggplot2 cookbook has answers for most fairly basic questions like this.

To add error bars, calculate the upper and lower values of the error bars separately. Then plot using geom_errorbar().

http://www.cookbook-r.com/Graphs/Plotting_means_and_error_bars_(ggplot2)/

To remove all legends use

theme(legend.position="none")

For more control, there are a number of other options.

http://www.cookbook-r.com/Graphs/Legends_(ggplot2)/