小编Aar*_*son的帖子

如何使用ImageGrid将标签添加到颜色栏?

在上一个问题中, ImageGrid中的colobar标签matplotlib有一个向颜色栏添加标签的解决方案,但是这在当前版本中似乎已被打破。

我尝试过的平台:

  • 带机盖的Mac:
    • 的Python:2.7
    • matplotlib:1.4.3-6
  • Linux:
    • 的Python:2.7
    • matplotlib:1.3.1

以下是上一个问题的代码,以及一些在iPython笔记本中运行的额外代码:

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import AxesGrid

def get_demo_image():
    import numpy as np
    from matplotlib.cbook import get_sample_data
    f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
    z = np.load(f)
    # z is a numpy array of 15x15
    return z, (-3,4,-4,3)

def demo_grid_with_single_cbar(fig):
    """
    A grid of 2x2 images with a single colorbar
    """
    grid = AxesGrid(fig, 132, # similar to subplot(132)
                    nrows_ncols = (2, 2),
                    axes_pad = 0.0,
                    share_all=True,
                    label_mode = …
Run Code Online (Sandbox Code Playgroud)

python matplotlib python-2.7 colorbar

3
推荐指数
1
解决办法
1670
查看次数

标签 统计

colorbar ×1

matplotlib ×1

python ×1

python-2.7 ×1