如何在轮廓线f中添加边线,以制作一个3D网格

时间:2018-07-15 02:59:58

标签: python matplotlib scipy mplot3d contourf

在一个轮廓线f图中有某种绘制方式或制作边缘线吗?

我已经尝试过绘制线条,并使用zorder绘制边缘线,但是不起作用。  我正在工作的情节在下面。

我需要在contourf平面上画线,以便制作一个网格。

情节链接

enter image description here

代码:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

plt.close('all')
fig = plt.figure(num=None, figsize=(10, 8), dpi=80, facecolor='w', edgecolor='k')
fig2 = plt.figure(num=None, figsize=(10, 8), dpi=80, facecolor='w', edgecolor='k')
ax = fig.gca(projection='3d')
ax.set_xlabel('X', fontsize=14, fontweight='bold')
ax.set_ylabel('Y', fontsize=14, fontweight='bold')
ax.set_zlabel('Z', fontsize=14, fontweight='bold') 
cset = [[],[],[]]

#plot edge lines
for zx in range(0,120,20) :
    ax.plot([0, 1000], [0,0], zs=zx, color='k', zorder=-1)
    ax.plot([1000,1000], [0, 1000], zs=zx, color='k', zorder=-1)

for xy in range(0,1100,100) :
    ax.plot([xy,xy], [0,0], zs=[0,100], color='k', zorder=1)
    ax.plot([1000,1000], [xy,xy], zs=[0,100], color='k', zorder=-1)

for xy in range(0,1100,100) :
    ax.plot([0, 1000], [xy,xy], zs=0, color='k', zorder=-1)
    ax.plot([xy,xy], [0, 1000], zs=0, color='k', zorder=-1)

#plot right plans
for ix in range(0,1000,100) :
    for zx in range(0,100,20) :
        X = np.linspace(zx, zx+20, 43)
        Y = np.linspace(ix, ix+100, 28)
        X, Y = np.meshgrid(X, Y)
        varone = np.random.rand(75,28,43) * .455865 - 3
        Z = varone[0,:,:]
        #right
        cset[1] = ax.contourf(Z, Y, X, zdir='x', offset=1000,
                              levels=np.linspace(np.min(Z),np.max(Z),30),cmap='jet', zorder=-2)

# setting 3D-axis-limits: 
ax.set_xticks(np.arange(-100, 1100, 100)) #[np.arange(-100, 1100, 100)]
ax.set_yticks(np.arange(-100, 1100, 100)) #[np.arange(-100, 1100, 100)]
ax.set_xlim3d(-100,1100)
ax.set_ylim3d(-100,1100)
ax.set_zlim3d(120,-20)
plt.show()

0 个答案:

没有答案