简体   繁体   中英

Plotting a 2D contour set on 3D axes

I am trying to push the limits of the 3D plotting in mpl, I know that they are not a fully featured as they could be and other packages (Mayavi) exist. However I would like to do this in mpl if possible.

I am trying to plot a slice of a 3D array. Ideally I would like to plot an image at the base of my 3D array, however doing it as a filled contour set would be good enough. At the moment I am doing the following:

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
qcset = mpl.contour.QuadContourSet(ax,data[:,:,6],levels=[1])
ax.add_contour_set(qcset)
plt.show()

However this winds me up with blank axes. I have tried multiple permutations on these few lines but nothing seems to work.

How about using the matplotlib's higher-level contour function:

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
cset = ax.contour(data[:,1,1],data[1,:,1],data[1,1,:],zdir='z', offset=-40)
ax.set_zlim(-40, 40)
plt.show()

There are more examples here , specifically this one .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM