来源:自学PHP网 时间:2020-09-27 14:46 作者:小飞侠 阅读:次
[导读] matplotlib 多个图像共用一个colorbar的实现示例...
|
今天带来matplotlib 多个图像共用一个colorbar的实现示例教程详解
本文主要介绍了matplotlib 多个图像共用一个colorbar的实现示例,分享给大家,具体如下:
# -*- 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()
结果为:
|
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com