189 8069 5689

matplotlib多个图像共用一个colorbar的实现示例-创新互联

本文主要介绍了matplotlib 多个图像共用一个colorbar的实现示例,分享给大家,具体如下:

创新互联 - 成都服务器托管,四川服务器租用,成都服务器租用,四川网通托管,绵阳服务器托管,德阳服务器托管,遂宁服务器托管,绵阳服务器托管,四川云主机,成都云主机,西南云主机,成都服务器托管,西南服务器托管,四川/成都大带宽,机柜大带宽租用·托管,四川老牌IDC服务商
# -*- 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()

分享文章:matplotlib多个图像共用一个colorbar的实现示例-创新互联
文章源于:http://cdxtjz.cn/article/geige.html

其他资讯