Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 847
Merk Avatar asked Oct 29 '25 08:10

Merk


1 Answers

this did the job for me :

cbar.mappable.set_clim(0,1)
like image 152
SaimonPressHill Avatar answered Oct 31 '25 11:10

SaimonPressHill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!