1 matplotlib绘制折线图
from matplotlib import pyplot as plt
#设置图形大小
plt.figure(figsize=(20,8),dpi=80)
plt.plot(x,y,color="cyan",linestyle="",linewidth="",alpha=0.4,label="")
#设置网格
plt.grid(alpha="",linestyle="")
#设置图例
plt.legend(loc="",prop=my_font)
#设置图信息
plt.xlabel("时间",fontproperties=my_font)
plt.ylabel("时间",fontproperties=my_font)
plt.title("",fontproperties=my_font)
#保存
plt.savefig("./baidu.png")
plt.show()
matplotlib如何设置x轴的刻度
#设置显示中文
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="")
plt.xticks(x,["","",""],fontproperties=my_font,rotation=45)
绘制多条折线
# coding=utf-8
from matplotlib import pyplot as plt
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="/System/Library/Fonts/PingFang.ttc")
y_1 = [1,0,1,1,2,4,3,2,3,4,4,5,6,5,4,3,3,1,1,1]
y_2 = [1,0,3,1,2,2,3,3,2,1 ,2,1,1,1,1,1,1,1,1,1]
x = range(11,31)
#设置图形大小
plt.figure(figsize=(20,8),dpi=80)
plt.plot(x,y_1,label="自己",color="#4EAADE")
plt.plot(x,y_2,label="同桌",color="#DB7093",linestyle="--")
#设置x轴刻度
_xtick_labels = ["{}岁".format(i) for i in x]
plt.xticks(x,_xtick_labels,fontproperties=my_font)
# plt.yticks(range(0,9))
#绘制网格
plt.grid(alpha=0.9,linestyle='-.')
#添加图例
plt.legend(prop=my_font,loc="upper left")
#展示
plt.show()
显示结果:
1 matplotlib绘制折线图的更多相关文章
- python使用matplotlib绘制折线图教程
Matplotlib是一个Python工具箱,用于科学计算的数据可视化.借助它,Python可以绘制如Matlab和Octave多种多样的数据图形.下面这篇文章主要介绍了python使用matplot ...
- Python开发【模块】:matplotlib 绘制折线图
matplotlib 1.安装matplotlib ① linux系统安装 # 安装matplotlib模块 $ sudo apt-get install python3-matplotlib # 如 ...
- 【Python】matplotlib绘制折线图
一.绘制简单的折线图 import matplotlib.pyplot as plt squares=[1,4,9,16,25] plt.plot(squares) plt.show() 我们首先导入 ...
- matplotlib之折线图
1.案例一 # coding=utf-8 from matplotlib import pyplot as plt import random # 设置字体相关 from matplotlib imp ...
- Python绘制折线图
一.Python绘制折线图 1.1.Python绘制折线图对应代码如下图所示 import matplotlib.pyplot as pltimport numpy as np from pylab ...
- 用canvas绘制折线图
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- php中用GD绘制折线图
php中用GD绘制折线图,代码如下: Class Chart{ private $image; // 定义图像 private $title; // 定义标题 private $ydata; // 定 ...
- python中matplotlib画折线图实例(坐标轴数字、字符串混搭及标题中文显示)
最近在用python中的matplotlib画折线图,遇到了坐标轴 "数字+刻度" 混合显示.标题中文显示.批量处理等诸多问题.通过学习解决了,来记录下.如有错误或不足之处,望请指 ...
- UUChart的使用--iOS绘制折线图
UUChart是一个用于绘制图表的第三方,尤其适合去绘制折线图. 二.下载地址: https://github.com/ZhipingYang/UUChartView 三.使用 第一步.首先我们将下载 ...
随机推荐
- exception java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
1.情景展示 Java 报错信息如下: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 2.原因分析 首先,这是越界异常,但不是数组越 ...
- 关于python的四舍五入
参考https://blog.csdn.net/qq_39234705/article/details/82817703 四舍五入有很多相关资料,主要用两种方法round()和'%.2f' 两种方法取 ...
- unity序列化
什么是序列化 unity的序列化在unity的开发中起着举重足轻的地位,许多核心的功能都是基于序列化和反序列化来实现的.序列化简单来讲就是就是将我们所要保存的数据进行二进制存储,然后当我们需要的时候, ...
- 解析prototxt文件的python库 prototxt-parser(使用parsy自定义文件格式解析)
解析prototxt文件的python库 prototxt-parser https://github.com/yogin16/prototxt_parser https://test.pypi.or ...
- C++中rapidxml用法
转载:https://www.cnblogs.com/rainbow70626/p/7586713.html 解析xml是第三方库很多,例如:tingxml,这次学习一下rapidxml,rapidx ...
- git push ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/Operater9/guest' hint: Updates were rejected because the tip of your current bra
推送本地代码到github报错 git push报错 ! [rejected] master -> master (non-fast-forward) error: failed to push ...
- IfcBuildingElement
IfcBuildingElement /* Generated By: IFC Tools Project EXPRESS TO JAVA COMPILER: Do not edit this fil ...
- 【GMT43智能液晶模块】例程十六:LAN_TCPS实验——以太网数据传输
源代码下载链接: 链接:https://pan.baidu.com/s/1e5Qp-xASjlA0pje3S7TdIg提取码:9v37 复制这段内容后打开百度网盘手机App,操作更方便哦 GMT43购 ...
- webshot一款网页快照工具
webshot https://github.com/brenden/node-webshot Webshot provides a simple API for taking webpage scr ...
- Egret HTML5游戏开发指南
Egret HTML5游戏开发指南 下载地址:https://pan.baidu.com/s/1fuxllvmRhWXoWDwH4gxN9g 关注微信公众号获取提取码: 输入:egrt 获取提取码