zoukankan      html  css  js  c++  java
  • matplotlib-曲线和折线案例

    matplotlib-曲线和折线案例

    import matplotlib.pyplot as plt
    import numpy as np
    
    x = np.linspace(-5, 5, 100)
    print(x)
    y1 = 0.8 * x+10
    y2 = x * x
    
    plt.figure()
    plt.xlabel('X axis...')
    plt.ylabel('Y axis...')                                #设置坐标轴的文字标签
    
    ax = plt.gca()                                            # get current axis 获得坐标轴对象
    
    ax.spines['right'].set_color('blue')
    ax.spines['top'].set_color('red')         # 将右边 上边的两条边颜色设置为空 其实就相当于抹掉这两条边
    
    ax.xaxis.set_ticks_position('bottom')   
    ax.yaxis.set_ticks_position('left')          # 指定下边的边作为 x 轴   指定左边的边为 y 轴
    
    ax.spines['bottom'].set_color('yellow')
    ax.spines['left'].set_color('orange')
    
    ax.spines['bottom'].set_position(('data', 0))   #指定 data  设置的bottom(也就是指定的x轴)绑定到y轴的0这个点上
    ax.spines['left'].set_position(('data', 0))
    
    plt.plot(x, y1, linestyle='--')
    plt.plot(x, y2)
    
    plt.show()
    

      

    输出:

  • 相关阅读:
    HDU 1018 Big Number
    UVa 10603 倒水问题
    UVa 12108 特别困的学生
    UVa 1590 IP网络(简单位运算)
    UVa 12325 宝箱
    UVa 253 骰子涂色
    UVa 815 洪水!
    springmvc(2)处理器设配器和映射器
    SpringMVC(1)
    MyBatis(10)逆向工程
  • 原文地址:https://www.cnblogs.com/andy9468/p/9934988.html
Copyright © 2011-2022 走看看