2017-05-06 144 views
0

我想繪製這些條件的3D繪圖,但我在z(y<0) = np.sin(x(y<0))*math.exp(y(y<0))處得到「無法分配函數來調用」。我不確定我做錯了什麼。我比python更熟悉matlab。在python中繪製3D圖像

import numpy as np 
import matplotlib.pyplot as plot 
from mpl_toolkits.mplot3d import Axes3D 
from scipy.interpolate import interp2d 
from matplotlib import cm 
import math 
x= np.meshgrid(np.linspace(0,4*np.pi,200)) 
y=np.meshgrid(np.linspace(-2,2,200)) 
z = np.sin(x)*(y+1); 
z(y<0) = np.sin(x(y<0))*math.exp(y(y<0)) 
fig3=plot.figure(3) 
ax3 = fig3.gca(projection='3d') 
surf3 = ax3.plot_surface(x,y,z, cmap=cm.coolwarm, linewidth=0, 
antialiased=False) 
plot.autoscale(enable=True,axis='x',tight=True) #axis tight 
plot.xlabel('x') 
plot.ylabel('y') 
plot.zlabel('z') 

回答

0

在Python中,索引是用方括號[]代替Matlab的圓的做()