用matplotlib模块

#!usr/bin/env python
#encoding:utf-8 '''
__Author__:沂水寒城
功能:折线图、散点图测试
''' import random
import matplotlib
import matplotlib.pyplot as plt def list2mat(data_list,w):
'''
切片、转置
'''
mat=[]
res=[]
for i in range(0,len(data_list)-w+1,w):
mat.append(data_list[i:i+w])
for i in range(len(mat[0])):
one_list=[]
for j in range(len(mat)):
one_list.append(mat[j][i])
res.append(one_list)
return res def draw_pic_test():
'''
作图
'''
data_list=[]
for i in range(100):
data_list.append(random.randint(2,150))
month_list=range(1,11,1)
mat=list2mat(data_list,w=10)
for one_list in mat:
one_list=[int(one) for one in one_list]
plt.plot(month_list,one_list,"x-",label="test_zhexian")
plt.savefig('test_zhexian.png')
plt.close()
for one_list in mat:
one_list=[int(one) for one in one_list]
plt.scatter(month_list,one_list,marker='x',label='test_sandian',s=30)
plt.savefig('test_sandian.png')
plt.close() if __name__ == '__main__':
draw_pic_test()

结果

折线图

散点图

Python使用matplotlib模块绘制多条折线图、散点图的更多相关文章

  1. 利用pandas读取Excel表格,用matplotlib.pyplot绘制直方图、折线图、饼图

    利用pandas读取Excel表格,用matplotlib.pyplot绘制直方图.折线图.饼图 数据: 折线图代码: import  pandas  as pdimport  matplotlib. ...

  2. 可视化数据matplotlib之安装与简单折线图

    matplotlib是一个可视化数据的模块,安装前需要先安装Visual Studio Community:然后去https://pypi.python.org/pypi上查找matplotlib并下 ...

  3. Python交互图表可视化Bokeh:4. 折线图| 面积图

    折线图与面积图 ① 单线图.多线图② 面积图.堆叠面积图 1. 折线图--单线图 import numpy as np import pandas as pd import matplotlib.py ...

  4. 用matplotlib.pyplot画简单的折线图,直方图,散点图

    #coding=utf-8 """ 用matplotlib.pyplot画简单的折线图,直方图,散点图 """ import matplot ...

  5. 使用Python的pandas模块、mplfinance模块、matplotlib模块绘制K线图

    目录 pandas模块.mplfinance模块和matplotlib模块介绍 pandas模块 mplfinance模块和matplotlib模块 安装mplfinance模块.pandas模块和m ...

  6. Python数据分析-Matplotlib图标绘制

    Matplotlib介绍 Matplotlib是一个强大的Python绘图和数据可视化的工具包. Matplotlib的主要功能 Matplotlib是python中的一个包,主要用于绘制2D图形(当 ...

  7. Python中matplotlib模块解析

    用Matplotlib绘制二维图像的最简单方法是: 1.  导入模块 导入matplotlib的子模块 import matplotlib.pyplot as plt import numpy as ...

  8. python之 matplotlib模块之基本三图形(直线,曲线,直方图,饼图)

    matplotlib模块是python中一个强大的绘图模块 安装 pip  install matplotlib 首先我们来画一个简单的图来感受它的神奇 import numpy as np impo ...

  9. 为python安装matplotlib模块

    matplotlib是python中强大的画图模块. 首先确保已经安装python,然后用pip来安装matplotlib模块. 进入到cmd窗口下,执行python -m pip install - ...

随机推荐

  1. 阿里云centos 6安装iRedmail过程

    全新系统 yum update cd /root wget http://www.iredmail.com/iRedMail-0.8.7.tar.bz2 tar xvf iRedMail-0.8.7. ...

  2. Android开发 - Fragment与Activity生命周期比较

    1. Fragment的生命周期 见下图 2. 与Activity生命周期的对比 见下图 3. 代码场景演示实例 切换到该Fragment: AppListFragment(7649): onAtta ...

  3. Python取得系统进程列表

    一.上代码 import psutil for proc in psutil.process_iter(): try: pinfo = proc.as_dict(attrs=['pid', 'name ...

  4. 转:nginx基础概念(connection)

    在nginx中connection就是对tcp连接的封装,其中包括连接的socket,读事件,写事件.利用nginx封装的connection,我们可以很方便的使用nginx来处理与连接相关的事情,比 ...

  5. 如何查看页面是否开启gzip压缩

    F12 选择Network 表头右键: 如果开启了gzip则显示gzip,没有则是空. 上图是百度首页,显示已经进行gzip压缩.

  6. Python——UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal

    当字符串比较中有中文时,需要在中文字符串前加 u  转为unicode编码才可以正常比较. str == u"中文"

  7. anagrams 查找序列里具有相同字符但顺序不同的单词

    [LeetCode] Anagrams   Given an array of strings, return all groups of strings that are anagrams. Not ...

  8. jump-game i&&ii 能否跳出区间 贪心

    I: Given an array of non-negative integers, you are initially positioned at the first index of the a ...

  9. Linux 防火墙命令的操作命令CentOS

    service firewalld status; #查看防火墙状态 systemctl start firewalld.service;#开启防火墙 systemctl stop firewalld ...

  10. ORA-01940: 无法删除当前连接的用户

    删除用户报错 SQL> drop user ODI_SRC CASCADE; drop user ODI_SRC CASCADE * 第 1 行出现错误: ORA: 无法删除当前连接的用户 查看 ...