Scientific notation colorbar in matplotlib

前端 未结 3 1609
名媛妹妹
名媛妹妹 2020-12-07 16:46

I am trying to put a colorbar to my image using matplotlib. The issue comes when I try to force the ticklabels to be written in scientific notation. How can I force the scie

3条回答
  •  感情败类
    2020-12-07 17:48

    There is a more straightforward (but less customizable) way to get scientific notation in a ColorBar without the %.0e formatting.

    Create your ColorBar:

    cbar = plt.colorbar()
    

    And call the formatter:

    cbar.formatter.set_powerlimits((0, 0))
    

    This will make the ColorBar use scientific notation. See the example figure below to see how the ColorBar will look.

提交回复
热议问题