zoukankan      html  css  js  c++  java
  • python plb 教程 实现折线图 (令含有 题目,标识,颜色,中文乱码解决)源码

    代码:

     1 # -*- coding: utf-8 -*-
     2 import numpy as np
     3 import matplotlib.pyplot as plt
     4 import matplotlib as mpl
     5 mpl.rcParams['font.sans-serif'] = ['SimHei']
     6 mpl.rcParams['font.serif'] = ['SimHei']
     7 mpl.rcParams['axes.unicode_minus'] = False
     8 # 设置x,y轴的数值(y=sinx)
     9 x = np.linspace(0, 10, 1000)
    10 y = np.sin(x)
    11 # 创建绘图对象,figsize参数可以指定绘图对象的宽度和高度,单位为英寸,一英寸=80px
    12 plt.figure(figsize=(8, 4))
    13 # 在当前绘图对象中画图(x轴,y轴,给所绘制的曲线的名字,画线颜色,画线宽度)
    14 plt.plot(x, y, label="$sin(x)$", color="red", linewidth=2)
    15 # X轴的文字
    16 plt.xlabel("Time(s)")
    17 # Y轴的文字
    18 plt.ylabel("Volt")
    19 # 图表的标题
    20 plt.title("确诊")
    21 # Y轴的范围
    22 plt.ylim(-1.2, 1.2)
    23 # 显示图示
    24 plt.legend()
    25 # 显示图
    26 plt.show()
    27 # 保存图
    28 #plt.savefig("sinx.jpg")
  • 相关阅读:
    今天我正式走出公司...
    PHP图片处理函数
    PHP缓存知识-转载
    Nginx 服务器伪静态配置实例
    PHP防止跨站攻击的脚本
    <
    <
    <- OPENGL 10 NormalMAP ->
    <-OPENGL 9-> 阴影篇
    - OPENGL8
  • 原文地址:https://www.cnblogs.com/smartisn/p/12638523.html
Copyright © 2011-2022 走看看