使用參數zsort='max'
當你調用ax.bar3d()
解決您的問題(見here):
ax.bar3d(xpos,ypos,zpos, dx, dy, dz, color='b', alpha=1., zsort='max')
我使用this other question代碼的修改後的版本與您的問題發揮:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
data = np.array([[0,1,0,2,0],
[0,3,0,2,0],
[6,1,1,7,0],
[0,5,0,2,9],
[0,1,0,4,0],
[9,1,3,4,2],
[0,0,2,1,3], ])
column_names = ['a','b','c','d','e']
row_names = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']
fig = plt.figure()
ax = Axes3D(fig)
lx= len(data[0]) # Work out matrix dimensions
ly= len(data[:,0])
xpos = np.arange(0,lx,1) # Set up a mesh of positions
ypos = np.arange(0,ly,1)
xpos, ypos = np.meshgrid(xpos+0.5, ypos+0.5)
xpos = xpos.flatten() # Convert positions to 1D array
ypos = ypos.flatten()
zpos = np.ones(lx*ly)*1e-10
dx = 1. * np.ones_like(zpos)
dy = dx.copy()
dz = data.flatten()
ax.bar3d(xpos,ypos,zpos, dx, dy, dz, color='b', alpha=1., zsort='max')
plt.ion()
plt.show()
謝謝,@SaulloCastro這個修改幾乎是完美的。現在Z順序是正常的,除了酒吧的頂面。我將發佈所生成的新圖像。 – 2013-05-01 17:22:19
很高興聽到!郵政,我們可以看看它... – 2013-05-01 17:24:08
它已經在那裏。如果您有任何意見,請隨時編輯。謝謝! – 2013-05-01 17:33:40