-2

I generated a 2d array, in each row, there is a random x, random y and f(x,y). I chose random x and y because f(x, y) is very long to compute.

I used Axes3D from mpl_toolkits.mplot3d to draw the result :

ax.scatter(tableau[:,0], tableau[:,1], zs=tableau[:,2], c='r', marker='o')

The result is not useful. Impossible to understand the shape of f

draw of f with random x and y

Is there a better way to draw f(x,y)?

Soren
  • 14,402
  • 4
  • 41
  • 67

2 Answers2

0

If your goal is to see the shape of your function better you can rotate the axes with matplotlib method view_init(elev=None, azim=None); it sets the elevation and azimuth of the axes angle . For example:

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Test 3D function
X, Y, Z = axes3d.get_test_data(0.1)
ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5)

ax.view_init(elev, azim)

plt.draw()

With elev=30 and azim=45:

enter image description here

With elev=30 and azim=90:

enter image description here

With elev=0 and azim=90:

enter image description here

mforpe
  • 1,549
  • 1
  • 12
  • 22
  • Thanks for this answer. since the set of (x,y) is not regular the result is not realy better. I'll add the result as an answer to my question – Noureddine ERRAFAY May 07 '17 at 12:57
0

enter image description here

  fig = plt.figure()
  ax = fig.add_subplot(111, projection='3d')
  elev=70 
  azim=30
  X, Y, Z = tableau[:,0], tableau[:,1], tableau[:,2]
  ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5)

  ax.view_init(elev, azim)

  plt.draw()
Wheat Wizard
  • 3,982
  • 14
  • 34