zoukankan      html  css  js  c++  java
  • matplotlib的使用——picture in picture画中画的使用

    画中画显示的方法

    画中画显示呢,常常需要用到fig.add_axes()函数,其一共需要传入一个矩阵,矩阵中包含4个参数,分别为[left,bottom,width,height]。

    fig.add_axes()的使用方式

    fig.add_axes()函数传入参数的方式为:

    ax1 = fig.add_axes([left,bottom,width,height])
    

    其中left,bottom,width,height均代表百分比,代表其占整个图像的百分比。
    left为坐标轴最左侧举例边缘的百分比;
    bottom为坐标轴最下侧举例边缘的百分比;
    width代表左右坐标轴的距离;
    height代表上下坐标轴的距离;
    在这里插入图片描述

    应用示例

    import numpy as np
    import matplotlib.pyplot as plt
    
    fig = plt.figure()
    
    x = [1,2,3,4,5,6,7]
    y = [7,6,5,4,3,2,1]
    
    left,bottom,width,height = 0.1,0.1,0.8,0.8
    
    # 添加最大的图像
    ax1 = fig.add_axes([left,bottom,width,height])
    ax1.plot(x,y,'r')
    ax1.set_title("ax1")
    
    # 添加第一幅画中画
    left,bottom,width,height = 0.15,0.15,0.3,0.3
    ax2 = fig.add_axes([left,bottom,width,height])
    ax2.plot(x,y,'r')
    ax2.set_title("ax2")
    
    # 添加第二幅画中画
    left,bottom,width,height = 0.55,0.55,0.3,0.3
    ax3 = fig.add_axes([left,bottom,width,height])
    ax3.plot(x,y,'r')
    ax3.set_title("ax3")
    
    plt.show()
    

    实现结果为

    在这里插入图片描述

    天道酬勤 循序渐进 技压群雄
  • 相关阅读:
    多线程的同步锁和死锁
    多线程同步
    oracle11g导出表时会发现少表,空表导不出解决方案
    GET和POST两种基本请求方法的区别
    数据库优化
    JavaScript中的基本数据类型
    Spring Data Jpa简单了解
    单例和多例详解
    jsp九大内置对象
    JavaEE 前后端分离以及优缺点
  • 原文地址:https://www.cnblogs.com/wuyuan2011woaini/p/15681926.html
Copyright © 2011-2022 走看看