matplotlib 将两张数据视图在一起显示


import numpy as np
import pandas as pd
from matplotlib import pyplot as plt


if __name__ == "__main__":
    #第一组数据
    x1 = list(range(5))
    y1 = list(map(lambda x:x**2,x1))

    #第二组数据
    x2 = list(range(5,11))
    y2 = list(map(lambda x:x**2/2,x2))

    #做第一幅图 2*1矩阵
    ax1 = plt.subplot(121)
    #传入数据7
    ax1.plot(x1,y1)
    #为第一张图片设置标题
    plt.title('d1')

    ax2 = plt.subplot(122)
    #传入数据
    ax2.plot(x1,y1)
    #为第二张图片设置标题
    plt.title('d2')

    #删除子图
    plt.delaxes(ax2)
    
    plt.subplot(ax2)

    #绘制
    plt.show()

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM