Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wrong colorbar labels using mpld3

I am using mpld3 to draw some plots in a browser. The scatter-plot is showing the correct colors, but the colorbar for the plot has the wrong labels. The colorbar is always labeled from 0 to 1, although vmin and vmax are different. Any ideas?

f, a= plt.subplots(figsize=(10,10))
f.subplots_adjust(left=0.2, right=0.90, bottom=0.05, top=0.95,
  hspace=0.1, wspace=0.1)

im=a.scatter(xList,yList,s=40,vmin=-200,vmax=200,edgecolors='none',c=zList)
divider = make_axes_locatable(a)
cax = divider.append_axes("right", size="5%", pad=0.05)
cbar=plt.colorbar(im, cax=cax)
cbar.set_label('Magnetfeld [nt]', labelpad=10)

a.set_xlabel('Distanz [m]')
a.set_ylabel('Distanz [m]', labelpad=100)
a.set_title('korrigiertes Magnetfeld')
a.set_aspect('equal')

return render_template('upload=mobil.html',name=mpld3.fig_to_html(f,template_type="simple"))
like image 643
medit Avatar asked Apr 29 '26 03:04

medit


1 Answers

This looks like an mpld3 bug. Thanks for identifying it. I've opened an issue for it here. Patches welcome!

like image 97
Abraham D Flaxman Avatar answered May 03 '26 04:05

Abraham D Flaxman