2017-05-07 6 views
-2

2次元配列を生成しました。各行にランダムx、ランダムyとf(x、y)があります。 f(x, y)は非常に計算時間が長いため、ランダムxyを選択しました。Python:ランダムなxとyを持つ3次元関数を描画する最良の方法

私は結果を描画するmpl_toolkits.mplot3dからAxes3Dを使用:

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

結果は有用ではありません。 f(x、y)を描画するためのより良い方法はあり

F

draw of f with random x and y

の形状を把握することは不可能?

答えて

0

あなたの目標は、関数の形状をよりよく見たい場合は、matplotlibメソッドview_init(elev=None, azim=None)で軸を回転させることができます。軸角度の仰角と方位角を設定します。例えば:ELEVと

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() 

= 30とアジム= 45:ELEVと

enter image description here

= 30とアジム= 90:ELEV = 0で

enter image description here

アジム= 90:

この回答のためのの

+0

感謝。 (x、y)の集合は規則的ではないので、結果は本当に良くない。私は質問を答えとして結果を追加します –

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() 
関連する問題