matplotlib绘图基础--1
来源:互联网 发布:淘宝屈臣氏官方旗舰店 编辑:程序博客网 时间:2024/06/07 20:34
matplotlib库是专门用于开发2D图表(包括3D图表)的,近年来被广泛用于科技圈。
安装:
1.Anaconda
conda installmatplotlib
2.Debian-Ubuntu Linux
sudoapt-get install python-matplotlib
3.Fedora-Redhat Linux
sudoyum install python-matplotlib
更多内容可以访问我的个人网站https://www.cjluzzl.cn
架构
1.Scripting 脚本层
2.Artist 表现层
3.Backend 模型层
Backend层
matplotlibAPI位于该层,这些API是用来在底层实现图形元素的一个个类。
FigureCanvas 对象实现了绘图区域这一概念
Renderer 对象在FigureCanvas上绘图
Event 对象处理用户输入(键盘和鼠标事件)
Artist层
中间层为Artist层。图层中所有能看到的元素都属于Artist对象,即标题、轴标签、刻度等组成图形所有元素的都是Artist对象的实例。图形中每个元素的实例在层级结构中有着自己的位置
Artist类分为两种:原始(primitive)和复合(composite)
Scripting层
包含pyplot借口
生成一幅简单的交互式图表
In [1]: import matplotlib.pyplot as plt
In [2]: plt.plot([1,2,3,4])
Out[2]: [<matplotlib.lines.Line2D at0x6578908>]
In [3]: plt.show()
设置图形属性
1.设置坐标轴取值范围
plt.axis([0,5,0,20])
传入一个列表,四个值分别为[xmin,xmax,ymin,ymax]用来指定x轴和y轴的取值范围
2.设置标题
plt.title(“Myfirst plot”)
plt.plot([1,2,3,4],[1,4,9,16],'ro')
plt.show()
matplotlib 与 numpy
In [12]: import math
In [13]: import numpy as np
In [14]: t = np.arange(0,2.5,0.1)
In [15]: y1 = map(math.sin,math.pi*t)
In [16]: y2 =map(math.sin,math.pi*t+math.pi/2)
In [17]: y3 =map(math.sin,math.pi*t-math.pi/2)
In [18]:plt.plot(t,y1,'b*',t,y2,'g^',t,y3,'ys')
Out[18]:
[<matplotlib.lines.Line2D at0xa1d9780>,
<matplotlib.lines.Line2D at 0xa1d9828>,
<matplotlib.lines.Line2D at 0xa1d9c18>]
In [19]: plt.show()
- matplotlib绘图基础--1
- matplotlib绘图基础
- matplotlib绘图基础
- matplotlib绘图基础
- matplotlib绘图基础
- matplotlib绘图基础--2
- matplotlib绘图基础--3
- matplotlib绘图基础
- matplotlib绘图基础--笔记
- [053]matplotlib绘图基础
- matplotlib 2D绘图基础
- Matplotlib基础绘图函数示例
- matplotlib学习之绘图基础
- matplotlib学习之绘图基础
- matplotlib学习之绘图基础
- matplotlib学习之绘图基础
- matplotlib学习之绘图基础
- Python3.绘图基础matplotlib.pyplot
- kindeditor-4.1.10富文本编译器的使用
- 音视频学习路线 知乎答主
- 消息中间件 rabbitmq 级联-Federation
- stdin,stdout,stderr
- js开发: JavaScript 中的面向对象的初步理解
- matplotlib绘图基础--1
- 消息中间件 RabbitMQ 三种分布式架构区别 Clustering Federation Shovel
- 安装GeoServer并配置数据存储
- 两栈共享空间
- 3DS更新R4烧录卡内核
- 数据库的查询优化技术
- VS2015使用MFC编程时struct结构变量报错
- 售前
- stdin,stdout,stderr