matplotlibmplot3d

Changing the colorbar limits in a mpl_toolkits.mplot3d plot


I am trying to change the clim in a mpl_toolkits.mplot3d plot using this method:

fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(111, projection='3d')
p = ax.scatter(x_, y_, z_, c='gray', s=0.25, alpha='0.5')
cbar = fig.colorbar(p)
cbar.set_clim(0,1)

This does not work and gives a Deprecation Warning:

MatplotlibDeprecationWarning: 
    The set_clim function was deprecated in Matplotlib 3.1 and will be removed in 3.3.
    Use ScalarMappable.set_clim instead.

Did anyone figure out how to change the colorbar limits in a Axes3D plot?

Thanks in advance!


Solution

  • this did the job for me :

    cbar.mappable.set_clim(0,1)