python用matplotlib画折线图
折线图: import matplotlib.pyplot as plt
y1=[10,13,5,40,30,60,70,12,55,25]
x1=range(0,10)
x2=range(0,10)
y2=[5,8,0,30,20,40,50,10,40,15]
plt.plot(x1,y1,label='Frist line',linewidth=3,color='r',marker='o',
markerfacecolor='blue',markersize=12)
plt.plot(x2,y2,label='second line')
plt.xlabel('Plot Number')
plt.ylabel('Important var')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
条形图
import matplotlib.pyplot as plt
y1=[10,13,5,40,30,60,70,12,55,25]
x1=range(0,20,2)
x2=range(1,21,2)
y2=[5,8,0,30,20,40,50,10,40,15]
plt.bar(x1,y1,label='Frist line')
#plt.bar(x2,y2,label='second line',color='r')
plt.xlabel('Plot Number')
plt.ylabel('Important var')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
直方图:
import matplotlib.pyplot as plt
population_ages = [22,55,62,45,21,22,34,42,42,4,99,102,
110,120,121,122,130,111,115,112,80,75,
65,54,44,43,42,48]
x=range(0,130,10)
plt.hist(population_ages,x,rwidth=0.8,color='r',histtype='stepfilled')
plt.xlabel('Plot Number')
plt.ylabel('Important var')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
散点图:
import matplotlib.pyplot as plt
population_ages = [22,55,62,45,21,22,34,42,42,4,99,102,
110,120,121,122,130,111,115,112,80,75,
65,54,44,43,42,48]
x=range(0,len(population_ages))
plt.scatter(x,population_ages,label='frist label',s=20)
help(plt.scatter)
plt.xlabel('x')
plt.ylabel('y')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
python用matplotlib画折线图的更多相关文章
- python中matplotlib画折线图实例(坐标轴数字、字符串混搭及标题中文显示)
最近在用python中的matplotlib画折线图,遇到了坐标轴 "数字+刻度" 混合显示.标题中文显示.批量处理等诸多问题.通过学习解决了,来记录下.如有错误或不足之处,望请指 ...
- Matplotlib学习---用matplotlib画折线图(line chart)
这里利用Jake Vanderplas所著的<Python数据科学手册>一书中的数据,学习画图. 数据地址:https://raw.githubusercontent.com/jakevd ...
- python使用matplotlib绘制折线图教程
Matplotlib是一个Python工具箱,用于科学计算的数据可视化.借助它,Python可以绘制如Matlab和Octave多种多样的数据图形.下面这篇文章主要介绍了python使用matplot ...
- 【Python】matplotlib绘制折线图
一.绘制简单的折线图 import matplotlib.pyplot as plt squares=[1,4,9,16,25] plt.plot(squares) plt.show() 我们首先导入 ...
- Python3 使用 matplotlib 画折线图
ChartUtil.py import matplotlib.pyplot as plt from pylab import mpl def plotLine(xData,yData,xLabel,c ...
- SAS 画折线图PROC GPLOT
虽然最后做成PPT里的图表会被要求用EXCEL画,但当我们只是在分析的过程中,想看看数据的走势,直接在SAS里画会比EXCEL画便捷的多. 修改起来也会更加的简单,,不用不断的修改程序然后刷新EXCE ...
- Matplotlib学习---用matplotlib画雷达图(radar chart)
雷达图常用于对多项指标的全面分析.例如:HR想要比较两个应聘者的综合素质,用雷达图分别画出来,就可以进行直观的比较. 用Matplotlib画雷达图需要使用极坐标体系,可点击此链接,查看对极坐标体系的 ...
- echars画折线图的一种数据处理方式
echars画折线图的一种数据处理方式 <!DOCTYPE html> <html> <head> <meta charset="utf-8&quo ...
- 使用OpenCV画折线图
使用OpenCV画直方图是一件轻松的事情,画折线图就没有那么Easy了,还是使用一个库吧: GraphUtils 源代码添加入工程 原文链接:http://www.360doc.com/content ...
随机推荐
- 转:自旋锁(spinlock)
自旋锁与互斥锁有点类似,只是自旋锁不会引起调用者睡眠,如果自旋锁已经被别的执行单元保持,调用者就一直循环在那里看是否该自旋锁的保持者已经释放了锁,"自旋"一词就是因此而得名. 由于 ...
- 1613. 最高频率的IP
Description Given a string[] lines, each line will have an ip address , find the ip address with the ...
- 蓝桥杯 ——积木问题——C++
问题描述: 小明最近喜欢搭数字积木.一共有10块积木,每个积木上有一个数字,0~9. 搭积木规则: 每个积木放到其它两个积木的上面,并且一定比下面的两个积木数字小. 最后搭成4层的金字塔形,必须用完所 ...
- Java并发编程(十四)-- 线程池实现原理
在上一章我们从宏观上介绍了ThreadPoolExecutor,本文将深入解析一下线程池的具体实现原理 原理解析 线程池状态 在ThreadPoolExecutor中定义了一个volatile变量,另 ...
- 开源评测系统hustoj-代码解读
非常感谢zhblue贡献了这么美丽的代码 为了开发适合自己学校的oj,努力研读代码中,不断的百度,调试,测试 对ubutun,linux的各种文件系统,进程系统,c编程都学习了不少 给大家分享下,希望 ...
- React使用Styled-Componets来添加样式
React使用Styled-Componets来添加样式 Styled-Comonents是用JS中ES6 语法的方式来管理CSS样式的一个组件,解决了在import CSS文件时样式重复 安装 项目 ...
- Git删除本地修改
git如何删除本地所有未提交的更改 git checkout . && git clean -xdf 一般 git clean都是配合git reset 使用的 如果你有的修改已经加入 ...
- ORM字段操作
django orm 建表字段 在django modle 中,我们定义的类,他的对象就是数据库表中的一行数据!!! django orm 基础 一:modle的各个字段: 在python中以code ...
- java基础知识总结--继承和接口
什么是继承?什么是接口?他们之间的区别和联系是什么? 什么是继承? 继承是使用已存在的类的定义作为基础建立新类的技术,新类的定义可以增加新的数据或新的功能,也可以用父类的功能.多个类中存在相同属性和行 ...
- helm-chart4,流程控制和变量
控制结构(模板说法中称为"动作")提供了控制模板生成流程的能力.Helm的模板语言提供了以下控制结构: if/ else用于创建条件块 with 指定范围 range,它提供了一个 ...