Reverse Y-Axis in PyPlot
There is a new API that makes this even simpler.
plt.gca().invert_xaxis()
and/or
plt.gca().invert_yaxis()
DisplacedAussie's answer is correct, but usually a shorter method is just to reverse the single axis in question:
plt.scatter(x_arr, y_arr)
ax = plt.gca()
ax.set_ylim(ax.get_ylim()[::-1])
where the gca()
function returns the current Axes instance and the [::-1]
reverses the list.
Use matplotlib.pyplot.axis()
axis([xmin, xmax, ymin, ymax])
So you could add something like this at the end:
plt.axis([min(x_arr), max(x_arr), max(y_arr), 0])
Although you might want padding at each end so that the extreme points don't sit on the border.