在ImageGrid中的colobar标签matplotlib [英] colobar label matplotlib in ImageGrid
本文介绍了在ImageGrid中的colobar标签matplotlib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用文档中的此功能通过matplotlib绘制漂亮的图.
I am using this function from the documentation to make a nice plot with matplotlib.
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 = "L",
cbar_location = "top",
cbar_mode="single",
)
Z, extent = get_demo_image()
for i in range(4):
im = grid[i].imshow(Z, extent=extent, interpolation="nearest")
#plt.colorbar(im, cax = grid.cbar_axes[0])
grid.cbar_axes[0].colorbar(im)
for cax in grid.cbar_axes:
cax.toggle_label(False)
# This affects all axes as share_all = True.
grid.axes_llc.set_xticks([-2, 0, 2])
grid.axes_llc.set_yticks([-2, 0, 2])
我想更改颜色条的标签,在颜色条上方或万一颜色条位于右侧"的情况下,标签也应移到侧面.
I would like to change add a label to the colorbar, above or in case the colorbar is located 'right', then the label should go to the side aswell.
只是改变
cbar = grid.cbar_axes[0].colorbar(im)
cbar.ax.set_label_text("$[a.u.]$")
做这份工作!
推荐答案
只是改变
cbar = grid.cbar_axes[0].colorbar(im)
cbar.ax.set_label_text("$[a.u.]$")
做这份工作!
这篇关于在ImageGrid中的colobar标签matplotlib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文