Colorbar for matplotlib plot_surface command

前端 未结 1 708
旧时难觅i
旧时难觅i 2020-11-30 03:17

I have modified the mplot3d example code for my application with Paul\'s help. The code reads:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyp         


        
相关标签:
1条回答
  • 2020-11-30 04:01

    You can use a proxy mappable object since your surface array is not mapped. The mappable simply converts the values of any array to RGB colors defined by a colormap.

    In your case you want to do this with the z1 array:

    import matplotlib.cm as cm
    m = cm.ScalarMappable(cmap=cm.jet)
    m.set_array(z1)
    plt.colorbar(m)
    
    0 讨论(0)
提交回复
热议问题