美文网首页
matplotlib画子图

matplotlib画子图

作者: 德先森的书 | 来源:发表于2018-04-25 10:48 被阅读0次

    import numpy as np

    fig = plt.figure()

    fig = plt.figure(figsize=(3, 3)) #设置图片大小

    fig.add_subplot(a,b,c) a行b列的,c代表位置

    ax1 = fig.add_subplot(2,1,1) #2行1列的第一个图
    ax2 = fig.add_subplot(2,1,2) #2行1列的第二个图

    作图

    ax1.plot(np.random.randint(1,5,5), np.arange(5),c="red")
    ax2.plot(np.arange(10)*3, np.arange(10),c="green")
    plt.show()


    untitled.png

    相关文章

      网友评论

          本文标题:matplotlib画子图

          本文链接:https://www.haomeiwen.com/subject/omuelftx.html