4

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!

gboffi
  • 22,939
  • 8
  • 54
  • 85
Merk
  • 171
  • 12

1 Answers1

8

this did the job for me :

cbar.mappable.set_clim(0,1)
  • The shortest answer solving one of the _stubbornest_ problem I ever faced... 6 hours of vain search solved in 9 characters `.mappable` ! Wow, Great !!! – Partha D. Sep 19 '21 at 13:44