I'm trying to add legend to a 3d bar, but with no success.
I'm getting the error:
AttributeError: 'Patch3D' object has no attribute '_facecolor2d'
A minimal code for reproducing: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for z in [10, 0]:
xs = np.arange(20)
ys = np.random.rand(20)
ax.bar(xs, ys, zs=z, zdir='y', label=str(z))
ax.legend()
plt.show()
How Can I add a legend to a 3d bar?