Python Matplotlib Colormap

前端 未结 3 1505
旧时难觅i
旧时难觅i 2020-12-18 10:34

I use the colormap \"jet\" to plot my graphics. But, I would like to have the lower values in white color and this colormap goes from blue to red colors. I also don\'t want

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-18 10:44

    There is another way to do the same without defining a new colobar. You can use the cmap.set_under method that defines the color to be used for all values below a given threshold. The threshold is defined during the pcolormesh :

    from matplotlib.pyplot import *
    import numpy as np
    
    mycmap = cm.get_cmap('jet')
    mycmap.set_under('w')
    
    pcolor(np.random.rand(10,10), cmap=mycmap, vmin=.1)
    colorbar()
    show()
    

提交回复
热议问题