我正在尝试用这些条件绘制3D图,但我在z(y<0) = np.sin(x(y<0))*math.exp(y(y<0))
得到了“无法分配调用函数”。我不确定我做错了什么。我对matlab比python更熟悉。
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')