我正在尝试使用Python Matplotlib使用contourf函数"绘制"多维数据集的面.这可能吗?
这与此处所做的类似,但显然我不能使用补丁.同样,我认为我不能像这样使用add_collection3d ,因为它只支持PolyCollection,LineColleciton和PatchCollection.
我一直在尝试使用contourf fig.gca(projection='3d').下面的玩具示例.
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
plt.close('all')
fig = plt.figure()
ax = fig.gca(projection='3d')
############################################
# plotting the 'top' layer works okay... #
############################################
X = np.linspace(-5, 5, 43)
Y = np.linspace(-5, 5, 28)
X, Y = np.meshgrid(X, Y)
varone=np.random.rand(75,28,43)
Z=varone[0,:,:]
cset = ax.contourf(X, Y, Z, zdir='z', offset=1,
levels=np.linspace(np.min(Z),np.max(Z),30),cmap='jet')
#see [1]
plt.show()
#################################################
# but now trying to plot a vertical slice.... #
################################################# …Run Code Online (Sandbox Code Playgroud)