I don't know how to put fill_between working the way you want it to, but I can provide an alternative using a 3D polygon:from numpy import *import matplotlib.pylab as pltfrom mpl_toolkits.mplot3d import Axes3Dfrom mpl_toolkits.mplot3d.art3d import Poly3DCollection # New import#x,y = genfromtxt("data.dat",unpack=True)# Generated some random dataw = 3x,y = np.arange(100), np.random.randint(0,100+w,100)y = np.array([y[i-w:i+w].mean() for i in range(3,100+w)])z = np.zeros(x.shape)fig = plt.figure()ax = fig.add_subplot(111, projection='3d')#ax.add_collection3d(plt.fill_between(x,y,-0.1, color='orange', alpha=0.3,label="filled plot"),1, zdir='y')verts = [(x[i],z[i],y[i]) for i in range(len(x))] + [(x.max(),0,0),(x.min(),0,0)]ax.add_collection3d(Poly3DCollection([verts],color='orange')) # Add a polygon instead of fill_betweenax.plot(x,z,y,label="line plot")ax.legend()ax.set_ylim(-1,1)plt.show()上面的代码生成一些随机数据.从中构建顶点,并使用这些顶点绘制多边形.这将为您提供所需的绘图(但不使用fill_between).结果是:The code above generates some random data. Builds vertices from it and plots a polygon with those vertices. This will give you the plot you wish (but does not use fill_between). The result is: 这篇关于mplot3D fill_between超出轴限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-01 23:29