Currently the points are being joined in the order they are entered into the graph. Is there a way to order from left to right from the x co-ordinate?
plt.errorbar(xvals, yvals, yerr=errors, linestyle='-', color='orange')
Currently the points are being joined in the order they are entered into the graph. Is there a way to order from left to right from the x co-ordinate?
plt.errorbar(xvals, yvals, yerr=errors, linestyle='-', color='orange')
Since you have matplotlib you have numpy installed, and you can use numpy to sort both x and y by the x-order.
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 8, .1)
np.random.shuffle(x)
y = np.sin(x)
sx = np.argsort(x) # find the order for sorting x
x2 = x[sx] # apply this to x
y2 = y[sx] # apply this to y
plt.plot(x, y, 'y')
plt.plot(x2, y2, 'r', linewidth=4)
plt.show()