How can I invert the y_axis? Z is a np.array.Thank you
Z=TempLake X,Y=np.meshgrid(range(Z.shape[0]+1),range(Z.shape[1]+1)) im = plt.pcolormesh(X,Y,Z.transpose(), cmap='hot') plt.colorbar(im, orientation='horizontal') plt.show()
I have this:
I need this:
In Matplotlib we can reverse axes of a graph using multiple methods. Most common method is by using invert_xaxis() and invert_yaxis() for the axes objects. Other than that we can also use xlim() and ylim(), and axis() methods for the pyplot object.
Looks like ax. invert_yaxis() solves it.
To get a reverse-order cumulative histogram in Matplotlib, we can use cumulative = -1 in the hist() method. Set the figure size and adjust the padding between and around the subplots.
As @Chris said, this can be done with:
ax = plt.gca() ax.invert_yaxis()
Before the 'plt.show()'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With