zoukankan      html  css  js  c++  java
  • 折线图-小案例

    01-设置全局字体+大小
    02-绘制多条直线
    03-折线图-蓝色点+红色线+坐标


    01-设置全局字体+大小

    import matplotlib.pyplot as plt
    import matplotlib  # 载入matplotlib完整库
    
    matplotlib.rcParams['font.family'] = 'Microsoft Yahei'  # 字体,改为微软雅黑,默认 sans-serif
    matplotlib.rcParams['font.size'] = 32  # 字体大小,整数字号,默认10
    
    a = range(10)
    x = a
    y = a
    plt.plot(x, y)  # 折线图
    plt.grid()  # 设置网格
    plt.show()  # 显示图形
    

      


    02-绘制多条直线

    import matplotlib.pyplot as plt
    import numpy as np
    import matplotlib  # 载入matplotlib完整库
    
    matplotlib.rcParams['font.family'] = 'Microsoft Yahei'  # 字体,改为微软雅黑,默认 sans-serif
    matplotlib.rcParams['font.size'] = 32  # 字体大小,整数字号,默认10
    
    a = np.arange(10)
    plt.figure(figsize=(20, 20), dpi=80)
    # 方法一:
    # plt.plot(a, a, a, a * 1.5, a, a * 3)  # 折线图
    # 方法二:
    plt.plot(a, a)  # 折线图
    plt.plot(a, a * 1.5)  # 折线图
    plt.plot(a, a * 3)  # 折线图
    
    plt.grid()  # 设置网格
    plt.show()  # 显示图形
    

      


    03-折线图-蓝色点+红色线+坐标

    import matplotlib.pyplot as plt
    import numpy as np
    import matplotlib  # 载入matplotlib完整库
    
    matplotlib.rcParams['font.family'] = 'Microsoft Yahei'  # 字体,改为微软雅黑,默认 sans-serif
    # matplotlib.rcParams['font.size'] = 32  # 字体大小,整数字号,默认10
    
    a = np.arange(10)
    # y = x ** 2
    x = a
    y = list(map(lambda i: i ** 2, a))
    
    plt.figure(figsize=(20, 20), dpi=80)
    
    plt.plot(x, y, color='r', markerfacecolor='blue', marker='o')
    for i, j in zip(x, y):
        plt.text(i + 0.3, j - 6, (i, j), ha='center', va='bottom', fontsize=30)  # 标记文本
    
    plt.legend(apha=0.1)
    
    plt.grid()  # 设置网格
    plt.show()  # 显示图形
    

      

  • 相关阅读:
    根据两个判断条件,加载数据库列表getList(state, receiveUserId);
    listview带着chackbox,判断是否选择
    前台ajax不能循环执行,需要向后台传值,后台循环 id in (1,2,3);
    前台交互,根据id、关键字查询、插入新数据到数据库
    synchronized(XXX.class)
    接口测试思路和方法
    概念——同步异步;回调、轮询;序列化
    用例设计三个方面
    jenkins-git-gradle配置项目
    jmeter_https
  • 原文地址:https://www.cnblogs.com/andy9468/p/9891204.html
Copyright © 2011-2022 走看看