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 三.使用 第一步.首先我们将下载 ...
随机推荐
- srs安装与ffmpeg推流
环境说明:ubuntu 16.04 当前目录为~/. 一. 下载 git clone https://github.com/ossrs/srs.git 二.部署SRS 关闭防火墙,执行如下命令. uf ...
- Future home of something quite cool.
我绑定二级域名的时候显示内页如下,怎么办??一级主域名没问题呀~ Future home of something quite cool.If you're the site owner, log i ...
- web项目脱敏白名单管理
写在前面 下午没事, 看一下同事写的脱敏白名单管理功能. 所谓的脱敏就是将页面中查询出的信息列表当中的身份证号及手机号等关键信息部分用*号代替.该功能主要思路是新增一个页面用于配置哪些页面以及页面中哪 ...
- mysql/mongodb监控之Percona Monitoring and Management (PMM) 2.1.0安装使用
Percona Monitoring and Management (PMM)是Percona Server一款开源的用于管理和监控MySQL和MongoDB性能的开源平台,通过PMM客户端收集到的D ...
- scrapy爬虫案例:用MongoDB保存数据
用Pymongo保存数据 爬取豆瓣电影top250movie.douban.com/top250的电影数据,并保存在MongoDB中. items.py class DoubanspiderItem( ...
- 求解未知数——yjy题库
/* 未知数 p1,p2,p3,p4,p5,满足: (1) p1 与 p3 均为 2 位的正整数:p5 为 3 位的正整数: (2) p2 与 p4 低两位(例:数值‘123’取低两位则为‘23’)数 ...
- ospf的路由更新和撤销总结
首先ospf 的报文有:hello报文,主要作用ospf 邻居建立及维护.dd报文,主要作用主从选举,序列号主从的确认,mtu的协商(可选).lsr 报文,主要作用向邻居请求lsa.lsu报文,主要作 ...
- Kubernetes 清除持续 Terminating 状态的Pods
强制删除所有Pods -- 谨慎使用 kubectl delete pods --all --grace-period=0 --force
- Consider defining a bean of type 'com.*.*.feign.*FeignClient' in your configuration.
Description: Field *FeignClient in com.*.*.service.* required a bean of type '***********' that coul ...
- VC 获取系统特殊文件夹的路径如:系统目录,桌面等
转载:https://blog.csdn.net/qq_23992597/article/details/50963343 如果需要,请在StdAfx.h中添加 #include <shlobj ...