Created
June 4, 2017 18:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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