【问题标题】:height of colorbar (matplotlib)颜色条的高度(matplotlib)
【发布时间】:2018-05-21 03:12:04
【问题描述】:

是否可以有一个小于图形高度的颜色条? 我知道我们可以用

调整颜色条的大小
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="3%", pad=0.05)
pl.colorbar(im, cax=cax)

size 只调整颜色条的宽度。但是高度呢?

我正在寻找右上角的颜色条,与图形的一半高度。

【问题讨论】:

    标签: python matplotlib


    【解决方案1】:

    您可以使用fig.add_axes 并根据需要微调参数:

    import matplotlib.pyplot as plt
    from mpl_toolkits.axes_grid1 import make_axes_locatable
    import numpy as np
    
    fig = plt.figure()
    ax = plt.subplot(111)
    im = ax.imshow(np.arange(100).reshape((10, 10)))
    
    c = plt.colorbar(im, cax = fig.add_axes([0.78, 0.5, 0.03, 0.38]))
    

    【讨论】:

      猜你喜欢
      • 2014-11-20
      • 2013-09-13
      • 1970-01-01
      • 2017-01-22
      • 2016-06-14
      • 2020-02-18
      • 1970-01-01
      • 1970-01-01
      • 2013-08-14
      相关资源
      最近更新 更多