Python matplotlib中的三维条形图存在剪裁问题

Python matplotlib中的三维条形图存在剪裁问题,python,matplotlib,mplot3d,Python,Matplotlib,Mplot3d,我有一个下面的代码,将创建一个三维条形图,可以看到下面 我遇到的问题是,图片中的一些条看起来是错误的。图中圈出了看起来不对的条。当将“zsort”更改为最大值、最小值或平均值时,这会有所帮助,但看起来仍然很糟糕。使用ax.view\u init更改视图也没有多大帮助 from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np import matplotli

我有一个下面的代码,将创建一个三维条形图,可以看到下面

我遇到的问题是,图片中的一些条看起来是错误的。图中圈出了看起来不对的条。当将“zsort”更改为最大值、最小值或平均值时,这会有所帮助,但看起来仍然很糟糕。使用ax.view\u init更改视图也没有多大帮助

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

  xAmplitudes = np.random.exponential(10,10000) #your data here
  yAmplitudes = np.random.normal(50,10,10000) #your other data here - must be same array length

  x = np.array(xAmplitudes)   #turn x,y data into numpy arrays
  y = np.array(yAmplitudes)   #useful for regular matplotlib arrays

  fig = plt.figure(figsize=(30, 30)) #create a canvas, tell matplotlib it's 3d
  ax = fig.add_subplot(111, projection='3d')

  #make histogram stuff - set bins - I choose 20x20 because I have a lot of data
  hist, xedges, yedges = np.histogram2d(x, y, bins=(25,25))
  xpos, ypos = np.meshgrid(xedges[:-1]+xedges[1:], yedges[:-1]+yedges[1:])

  xpos = xpos.flatten()/1.
  ypos = ypos.flatten()/1.
  zpos = np.zeros_like (xpos)

  dx = xedges [1] - xedges [0]
  dy = yedges [1] - yedges [0]
  dz = hist.flatten()

  cmap = cm.get_cmap('jet') # Get desired colormap - you can change this!
  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(xpos, ypos, zpos, dx, dy, dz, color=rgba, zsort='max')
  plt.title("")
  plt.xlabel("")
  plt.ylabel("")
  plt.savefig("")
  ax.view_init(30, -40)
  plt.savefig('3dplot.png')
  plt.show()

  print('ax.azim {}'.format(ax.azim))
  print('ax.elev {}'.format(ax.elev))

这个问题能解决吗

不是真的。这是一个尚未解决的问题。好的,谢谢你让我知道。不是真的。这是一个尚未解决的问题。好的,谢谢你让我知道。