Welcome to Code Sharer, a code gallery for creating, saving and sharing all kinds of code snippets.

R — Error bars.

Posted On: Friday, November 28, 2014 at 2:12 AM Last updated: Wednesday, December 3, 2014 at 4:00 PM

Plot error bars for both x and y in R 
x<- c(1, 2, 3, 4, 5, 6)  #declare x
y<- x*(-1/2) #declare function of x
Erroriny<- c(0.33, 0.33,0.33, 0.33, 0.33, 0.33) #Error values in y
ylo<- y-Erroriny
yhi<- y+Erroriny
plot(x, y, type="p", pch=19, ylim=c(min(ylo), max(yhi)))
Errorinx<- c(0.33, 0.33,0.33, 0.33, 0.33, 0.33) #Error values in x
xlo<- x-Errorinx
xhi<- x+Errorinx
plot(x, y, type="p", pch=19, xlim=c(min(xlo), max(xhi))) #pch=point type, type=graph type.
segments(x, ylo, x, yhi)
segments(xlo, y, xhi, y)

Ryan Bradley-Evans (Admin)

Joined on
Contributed 16 Snips

Get Social and Share

Tags