Skip to content

Instantly share code, notes, and snippets.

@jonesor
Created June 4, 2017 18:19
Show Gist options
  • Save jonesor/253c484cda7e336f3889bfc11281e536 to your computer and use it in GitHub Desktop.
Save jonesor/253c484cda7e336f3889bfc11281e536 to your computer and use it in GitHub Desktop.
A simple example showing how to add error bars to a bar plot.
#bar heights
x<- c(1,2,3,2,4)
#standard error values
sem <- c(.5,.4,.2,.4,.2)
#bar labels
lab <- c("A","B","C","D","E")
#basic plot
d<-barplot(x,names.arg = lab,ylim=c(0,5))
#adding error bars
arrows(x0 = d,y0 = (x-sem),x1 = d,y1 = (x+sem),code = 3,length=0.1,angle=90)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment