I\'m plotting some data sets with linear fits. I want the linear fit to have the same color as the plotted data (error bars). How can I get that color?
You might try this:
x = np.arange(10)
y = np.arange(10)
err = np.ones(10)
ebar = plt.errorbar(x,y, yerr=err)
color = ebar[0].get_color()
ebar
is a container of artist, so you might modify the index in the last line to match the artist you want to get color from.
You can also easily set the color of the errorbar, so you know exactly what color they are without checking it:
ebar = plt.errorbar(x,y, yerr=err, ecolor='y')