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()
原文地址:https://www.cnblogs.com/Niuxingyu/p/10531219.html