I have a file named J.txt that has data in 3 columns, the third being the value for the error bar (symmetrical) like this:
2454501.81752 0.0018087812 9.69699358080375E-005
2454537.77104 0.0030887732 0.0001610068
2454603.70872 0.0022500182 0.0001230047
2454640.56455 0.0013261298 7.57575739971879E-005
2454662.63581 0.0017888998 9.91743434734387E-005
and I have the following code:
import numpy as np
import matplotlib.pyplot as plt
plt.plotfile('J.txt', delimiter=' ', cols=(0, 1),
names=('V', 'V-B'), marker='o', markersize=2, markeredgewidth=0.1, markeredgecolor='black',
color= 'green', label= "Cluster", linestyle='None', newfig=False)
plt.show()
I'm stuck trying to add the error bars to the plot because I don't know how to relate the columns in the file to plt.errorbar (if that's what I should be using).
Cheers.
plt.plotfile(), but you could first load the data using numpy withnp.loadtxt()and then just useplt.errorbar(), supplying the third column to theyerryerr(orxerr) keyword.capsizein the functionplt.plotfile()will do the trick.