I have a numpy array [(a1, x1), (a2, x2), ..., (a100, x100)] and I need to plot it such that a is my y-axis and x is my x-axis.
I know that it would be easier to have [a1, a2, ..., a100] and [x1, x2, ..., x100] as separate arrays to plot, but I'm doing a project, and I've been specifically told to do it this way, but am struggling.
Attempt 1 gave me a graph, but I think it's plotted a graph of a and x values against their numbers of order in the array.
Attempt 2, which was suggested by a matplotlib website just gave me a long error message.
# attempt 1
plt.plot(array,'r.')
plt.show()
plt.close()
# attempt 2
plt.plot(array_1[0], array_1[1:],'r.')
plt.show()
plt.close()
Any advice would be greatly appreciated. Thank you!
a, x = array.Tfollowed byplt.plot(a,x), or unpack with the*operator:plt.plot(*array.T). In this sequenceTis for transpose and loosely stated*(a,b,c,d) = a,b,c,d