1
我希望做一個類似於found here情節,與簡單的區別,我想從中心每個點設置的距離。也就是說,由於情節的一部分是一個圓圈,我希望每個點都離中心有一段可以確定的距離。Matplotlib:繪製二維數組徑向使3D散點圖
我一開始,考慮到前面提到的答案的簡單修改:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib
import numpy as np
from scipy.interpolate import interp1d
from matplotlib import cm
from matplotlib import pyplot as plt
step = 0.04
maxval = 1.0
fig = plt.figure()
ax = Axes3D(fig)
# u here would define the desired distance from radial axis
# u=np.array([0,1,2,1,0,2,4,6,4,2,1])
v=np.array([4,4,6,3,6,4,1,4,4,4,4])
r=np.array([0,1,2,3,4,5,6,7,8,9,10])
f=interp1d(r,u)
# walk along the circle
p = np.linspace(0,2*np.pi,len(r))
R,P = np.meshgrid(r,p)
# transform them to cartesian system
X,Y = R*np.cos(P),R*np.sin(P)
Z=f(R)
ax.scatter(X, Y, Z)#, rstride=1, cstride=1, cmap=cm.jet)
ax.set_xticks([])
fig.savefig(str(output_prefix + '3d..png'), dpi=(200))
我嘗試使用interp2d來添加u
變量註釋掉上面,但沒有運氣。更改Z
到陣列u
扔了錯誤的X,Y和Z必須是相同的尺寸("Argument 'zs' must be of same size as 'xs' "
,可以理解爲X和Y現在插值)什麼是我需要做什麼?任何提示將不勝感激!