zoukankan      html  css  js  c++  java
  • matplotlib 基础

    plt.figure(2)          #创建图表2
    plt.figure(1)          #创建图表1
    ax1=plt.subplot(211)   # 在上面 最近的 图表1上 创建子图1
    ax2=plt.subplot(212)   # 在上面 最近的 图表2上 创建子图2
    ax3=plt.subplot(212)   # 在同一幅子图2 创建子图3
    x=np.linspace(0,3,100)
    for i in xrange(5):
        plt.figure(2)      #选择图表1
        plt.plot(x,np.exp(i*x/3),label="exp(i*x/3)",color="black",linewidth=2)
        plt.xlabel("Time(s)")
        plt.ylabel("V2")
        plt.title("V2 example")
        #plt.xlim(0,100)
        #plt.ylim()
    
        plt.sca(ax1)      #选择图表1的子图1
        plt.plot(x,np.sin(i*x),label="sin(i*x)",color="blue",linewidth=2)
        plt.xlabel("Time(s)")
        plt.ylabel("V1-1")
        plt.title("V1-1 example")
        #plt.savefig("test1.pdf", dpi=120)
        #plt.xlim(0,100)
        # plt.ylim()
    
        plt.sca(ax2)      #选择图表1的子图2
        plt.plot(x,np.cos(i*x),label="cos(i*x)",color="green",linewidth=2)
        plt.sca(ax3)
        plt.plot(x,i*x,label="x",color="red",linewidth=2)
        plt.xlabel("Time(s)")
        plt.ylabel("V2-2")
        plt.title("V2-2 example")
        plt.xlim(0,1.5)
        plt.ylim(0,4)
        #plt.savefig("test2.pdf",dpi=120)
    plt.show()
    
    fig=plt.gcf()    # get current figure
    axes=plt.gca()   # get current axes
    print(fig,axes)
    
    plt.figure(3)
    x3=np.linspace(0.10,5)
    lines=plt.plot(x3,np.sin(x3),x3,np.cos(x3))
    plt.setp(lines,color="r",linewidth=2.0)
    #plt.show()
    print(lines.get_linewidth(), plt.getp(lines[0],"color"), plt.getp(lines[1]))
    

      

  • 相关阅读:
    大一励志的我,现在已经大三了
    Jenkins+K8s实现持续集成
    Jenkins搭建自动化测试环境
    软件开发式样书 6
    软件开发式样书 5
    软件开发式样书 4
    软件开发式样书 3
    软件开发式样书 2
    软件开发式样书 1
    Git学习笔记
  • 原文地址:https://www.cnblogs.com/skyEva/p/5869542.html
Copyright © 2011-2022 走看看