2016-06-14 52 views
1

私は長さを表す3つの数字を持っています。各数値は、x、y、z軸上のオブジェクトの長さです。私が表現したいオブジェクトは変形された球です(おそらく)。楕円体のプロット

これら3つの長さを指定することで、このオブジェクトを3Dでプロットする方法はありますか?

私はこれから行きたいと思います:このような何かに

enter image description here

は、例えば(私は絵を拡張した):

enter image description here

私が撮ってみました次のコード(Ellipsoid creation in Python)を使用して、x、y、zの定義で少し再生してください:

from mpl_toolkits.mplot3d import Axes3D 
import matplotlib.pyplot as plt 
import numpy as np 

phi = np.linspace(0,2*np.pi, 256).reshape(256, 1) # the angle of the projection in the xy-plane 
theta = np.linspace(0, np.pi, 256).reshape(-1, 256) # the angle from the polar axis, ie the polar angle 
radius = 4 

# Transformation formulae for a spherical coordinate system. 
x = radius*np.sin(theta)*np.cos(phi) 
y = radius*np.sin(theta)*np.sin(phi) 
z = radius*np.cos(theta) 

fig = plt.figure(figsize=plt.figaspect(1)) # Square figure 
ax = fig.add_subplot(111, projection='3d') 
ax.plot_surface(x, y, z, color='b') 

しかし、私は私が欲しいものに到達することはできません。私に手を差し伸べてもらえますか?

+0

あなたは答えを読めば、そのコードがプロットされた上で翻訳を使用します球、楕円ではありません。 –

答えて

3
  1. あなたはxyzのための異なる半径を使用する必要があり、実際に効果を見るために
  2. を調整し、ax.set_aspect(1.0)を使用するそれ以外の場合は、プロットビューは楕円体を持っている(球
  3. に、戻って拡大されます中央にない軸整列/ゼロ:回転および/またはxyz