oskar szarowicz
oskar szarowicz

Reputation: 133

"Invert" Axis on Matplotlib / Seaborn

Good evening/morning/evening ! I am only a leisure programmer so I appologise if this question has been answered on here before under a different title, I didn't know what to search for.

If you see below I have plotted two graphs, one a 2d and the other a 3d using matplotlib. enter image description here

My issue is that I wish for (0,0) to be in the bottom left corner and a step to the right to be +1 and a step upwards to be -1. Instead of having x increase and y decrease. If it is needed I will post the entire code for these plots but they have both been done conventionally with seaborn.heatmap(z) and ax.plot_surface(x,y,z).

Also I am using the following line I found on here: ax = fig.add_subplot(2, 1, 1) Could someone please explain the parameters of this function to me I am struggling to understand what they mean.

Any help is greatly appreciated and again I apologise if this has been posted before :)

Upvotes: 1

Views: 4302

Answers (1)

DapperDuck
DapperDuck

Reputation: 2859

In matplotlib:

If you want to invert the x-axis:

ax.invert_xaxis()

If you want to invert the y-axis:

ax.invert_yaxis()

If you want to invert the z-axis:

ax.invert_zaxis()

I'm pretty sure that these functions will work in seaborn as well, since it is built on top of matplotlib!

Upvotes: 4

Related Questions