test_colorbar.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:matplotlib-colorbar 作者: ppinard 项目源码 文件源码
def test_colorbar_example2():
    with cbook.get_sample_data('grace_hopper.png') as fp:
        data = np.array(plt.imread(fp))

    fig = plt.figure(figsize=(8, 6))
    ax = fig.add_subplot("111", aspect='equal')
    norm = matplotlib.colors.Normalize(vmin=-1.0, vmax=1.0)
    mappable = ax.imshow(data[..., 0], cmap='viridis', norm=norm)
    colorbar = Colorbar(mappable, location='lower left')
    colorbar.set_ticks([-1.0, 0, 1.0])
    ax.add_artist(colorbar)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号