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绘制折线图的更多相关文章

  1. python使用matplotlib绘制折线图教程

    Matplotlib是一个Python工具箱,用于科学计算的数据可视化.借助它,Python可以绘制如Matlab和Octave多种多样的数据图形.下面这篇文章主要介绍了python使用matplot ...

  2. Python开发【模块】:matplotlib 绘制折线图

    matplotlib 1.安装matplotlib ① linux系统安装 # 安装matplotlib模块 $ sudo apt-get install python3-matplotlib # 如 ...

  3. 【Python】matplotlib绘制折线图

    一.绘制简单的折线图 import matplotlib.pyplot as plt squares=[1,4,9,16,25] plt.plot(squares) plt.show() 我们首先导入 ...

  4. matplotlib之折线图

    1.案例一 # coding=utf-8 from matplotlib import pyplot as plt import random # 设置字体相关 from matplotlib imp ...

  5. Python绘制折线图

    一.Python绘制折线图 1.1.Python绘制折线图对应代码如下图所示 import matplotlib.pyplot as pltimport numpy as np from pylab ...

  6. 用canvas绘制折线图

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. php中用GD绘制折线图

    php中用GD绘制折线图,代码如下: Class Chart{ private $image; // 定义图像 private $title; // 定义标题 private $ydata; // 定 ...

  8. python中matplotlib画折线图实例(坐标轴数字、字符串混搭及标题中文显示)

    最近在用python中的matplotlib画折线图,遇到了坐标轴 "数字+刻度" 混合显示.标题中文显示.批量处理等诸多问题.通过学习解决了,来记录下.如有错误或不足之处,望请指 ...

  9. UUChart的使用--iOS绘制折线图

    UUChart是一个用于绘制图表的第三方,尤其适合去绘制折线图. 二.下载地址: https://github.com/ZhipingYang/UUChartView 三.使用 第一步.首先我们将下载 ...

随机推荐

  1. Fluent使用UDF遇见Received signal SIGSEGV

    Fluent版本:19.0 究其原因,一般是因为我们编写的UDF当中指针错误,导致未能正确获取Fluent一些变量的值,从而造成该错误. 下面我们通过调试手段来为了重现该错误,直观查看错误原因. 我们 ...

  2. 使用GParted调整ubuntu根目录空间大小

    一.背景 Win10系统下安装ubuntu16.04双系统-常见问题解答 由于安装双系统时,ubuntu分区设置如下: 1) 主分区 ext4 / 30720MB 2) 主分区 swap area 8 ...

  3. easyui datagrid合并相同数据的单元格。

    /** * 根据作用域填充单元格 */ function mergeCellsByField(tableID, colList) { var ColArray = colList.split(&quo ...

  4. 《自然语言理解(Natural Language Understanding)》(2016-03-17)阅读笔记

    原文链接:https://yq.aliyun.com/articles/8301 作者:李永彬 发布时间:2016-03-17 16:37:47 自然语言理解(Natural Language Und ...

  5. 公司-IT-Yahoo:百科

    ylbtech-公司-IT-Yahoo:百科 雅虎(英文名称:Yahoo!,NASDAQ:YHOO)是美国著名的互联网门户网站,也是20世纪末互联网奇迹的创造者之一.其服务包括搜索引擎.电邮.新闻等, ...

  6. js代码突然在花括号回车自动多加了一个大括号

    js代码突然在花括号回车自动多加了一个大括号. 检查发现,前面有一个行带有左括号的注释行.

  7. ThinkPHP5中模型关联关系一对一,一对多

    TP5 返回json反斜杠前面转义了class XinDai extends Controller{ public function index(){ $res = [ ['logo'=>'/i ...

  8. error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.

    . . . . . 今天从 github 上 clone 代码的时候,出现了一个错误,重试多次后仍然出现,错误如下: >$ git clone https://github.com/BOINC/ ...

  9. start & stop kafka cluster shell script

    kafka_start_cluster.sh #!/bin/bash brokers="kafka-server-1 kafka-server-2 kafka-server-3" ...

  10. EasyDSS高性能RTMP、HLS(m3u8)、HTTP-FLV、RTSP流媒体服务器解决方案之CDN内容分发网络

    背景分析 EasyDSS流媒体解决方案提供一站式的转码.点播.直播.录像.检索.时移回放服务,极大地简化了开发和集成的工作,并且EasyDSS支持多种特性,完全能够满足企业视频信息化建设方面的需求.其 ...