2

I'm using matplotlib to produce a 3d trisurf graph. I have everything working except that I would like to invert the y-axis, so that the origin is 0,0 not 0,100. I've looked through the matplotlib axes3d API and cannot figure out how to do this. Here is my code:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm

# my data, xs=xaxis, ys=yaxis, zs=zaxis
mortar_xs = []
cycles_ys = []
score_zs = []

#... populate my data for the 3 arrays: mortar_xs, cycles_ys, score_zs

# plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_trisurf(mortar_xs,cycles_ys,score_zs,cmap=cm.coolwarm)
ax.set_zlim(bottom=0.0,top=1.0) 
ax.legend()
ax.set_xlabel("# Mortar")
ax.set_ylabel("# Goals")
ax.set_zlabel("# Score")
plt.show()

My graph produced is the following, but I need the '# Goals' or the y-axis inverted, so that the origin is 0,0 not 0,100. If possible, I would like to do this without changing my data.

trisurf graph

ali_m
  • 71,714
  • 23
  • 223
  • 298
Dustin
  • 143
  • 2
  • 12

2 Answers2

2

tmdavison's comment is what I was looking for:

ax.set_ylim(0,100)

Or

ax.set_ylim(100,0)

Dustin
  • 143
  • 2
  • 12
1

The simplest method would be to use ax.invert_yaxis()

ali_m
  • 71,714
  • 23
  • 223
  • 298