本文主要介紹了matplotlib 多個(gè)圖像共用一個(gè)colorbar的實(shí)現(xiàn)示例,分享給大家,具體如下:
創(chuàng)新互聯(lián) - 成都服務(wù)器托管,四川服務(wù)器租用,成都服務(wù)器租用,四川網(wǎng)通托管,綿陽服務(wù)器托管,德陽服務(wù)器托管,遂寧服務(wù)器托管,綿陽服務(wù)器托管,四川云主機(jī),成都云主機(jī),西南云主機(jī),成都服務(wù)器托管,西南服務(wù)器托管,四川/成都大帶寬,機(jī)柜大帶寬租用·托管,四川老牌IDC服務(wù)商# -*- coding: utf-8 -*- """ Created on Sat Sep 5 18:05:11 2020 @author: 15025 draw three figures with one common colorbar """ import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import ImageGrid class Visualazation: def mainProgram(self): # Set up figure and image grid fig = plt.figure(figsize=(8, 4)) grid = ImageGrid(fig, 111, nrows_ncols=(1,3), axes_pad=0.15, share_all=True, cbar_location="right", cbar_mode="single", cbar_size="7%", cbar_pad=0.15, ) # Add data to image grid for ax in grid: im = ax.imshow(np.random.random((10,10)), vmin=0, vmax=1) # Colorbar ax.cax.colorbar(im) ax.cax.toggle_label(True) plt.show() if __name__ == "__main__": main = Visualazation() main.mainProgram()