Reverse Y-Axis in PyPlot Reverse Y-Axis in PyPlot python python

Reverse Y-Axis in PyPlot

There is a new API that makes this even simpler.




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.

You could also use function exposed by the axes object of the scatter plot

scatter = plt.scatter(x, y)ax = scatter.axesax.invert_xaxis()ax.invert_yaxis()