matplotlib bar3d中的可视化错误

matplotlib bar3d中的可视化错误,matplotlib,plot,visualization,mplot3d,Matplotlib,Plot,Visualization,Mplot3d,我正在matplotlib中绘制三维条形图 我发现了两个怪癖,当相邻酒吧的酒吧高度很大时,可视化是错误的。有人知道解决这个问题的办法吗 不可见条 使用此示例代码: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import matplotlib.cm as cm power = 5 n = 5 x = [1, 2, 3, 1, 2, 3, 1, 2, 3] # x coordinates

我正在matplotlib中绘制三维条形图

我发现了两个怪癖,当相邻酒吧的酒吧高度很大时,可视化是错误的。有人知道解决这个问题的办法吗

不可见条

使用此示例代码:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib.cm as cm   

power = 5

n = 5
x = [1, 2, 3, 1, 2, 3, 1, 2, 3]  # x coordinates of each bar
x = []
x = [x+1 for x in range(n)]
x = x * n 
y = []
for item in range(n):
    y = y + [item]*n
#y = f  # y coordinates of each bar
z = [0] * (n**2)  # z coordinates of each bar
dx = [1] * (n**2)  # Width of each bar
dy = [1] * (n**2)  # Depth of each bar
dz = list(range(n**2))
dz = [x**power for x in dz] 
fig = plt.figure(dpi=400)          #create a canvas, tell matplotlib it's 3d
ax = fig.add_subplot(111, projection='3d')

max_height = np.max(dz)   # get range of colorbars so we can normalize
min_height = np.min(dz)
# scale each z to [0,1], and get their rgb values
rgba = [cmap((k-min_height)/max_height) for k in dz] 

ax.bar3d(x, y, z, dx, dy, dz, color=rgba, zsort='average')
plt.title(r"plot title")
plt.xlabel("x axis")
plt.ylabel("y axis")
plt.show()
power
变量设置为
3
时,绘图良好。在
power=5
处,您可以看到数据点(5,4)不可见,显示后面的条形图。我相信这是由于酒吧之间的高度差异很大。当我用高但相似的高度进行测试时,问题没有出现