matplotlib 的 subplot, axes and axis
fig = plt.figure('多图', (10, 10), dpi=80) #第一个指定窗口名称,第二个指定图片大小,创建一个figure对象
plt.subplot(222) #2*2的第二个
plt.axis([0, 6, 0, 20]) #指定坐标轴范围
t = np.arange(0, 5, 0.2)
plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^') #可以连着写多个
plt.subplot(221) #2*2第一个,这句下面直接写绘图语句和设置语句
x = np.arange(-10, 10, 0.01)
y = np.exp(-x)*np.cos(2*np.pi*x)
plt.plot(x, y, 'r')
plt.xlim([-10, 10])
plt.show()
fig.savefig('linshi.png') #保存figure

2
源自 matplotlib subplot 子图 - Claroja - CSDN博客 http://blog.csdn.net/claroja/article/details/70841382
如果不指定figure()的axes,figure(1)命令默认会被建立,同样的如果不指定subplot(numrows, numcols, fignum)的轴axes,subplot(111)也会自动建立。这里,要注意一个概念当前图和当前坐标。所有绘图操作仅对当前图和当前坐标有效
当前的图表和子图可以使用plt.gcf()和plt.gca()获得,分别表示"Get Current Figure"和"Get Current Axes"。plt.sca (ax1)可以使ax1成为当前axes对象
plt.figure('第一个') # 创建第一个画板(figure)
plt.subplot(211) # 第一个画板的第一个子图
plt.plot([1, 2, 3], [1, 2, 3])
plt.subplot(212) # 第一个画板的第二个子图
plt.plot([4, 5, 6], [1, 2, 3])
plt.figure('第二个') # 创建第二个画板
plt.plot([4, 5, 6], [1, 2, 3]) # 默认子图命令是spbplot(111)
plt.figure('第一个') # 如果想对画板1操作,需调取画板1,此时调用中的子图是subplot(212)
plt.subplot(211) # 将调用中的子图变为subplot(211)
plt.title('Easy as 1, 2, 3')
plt.show()
要想重新设置,必须重新调用
3
源自 matplotlib subplot 子图 - Claroja - CSDN博客 http://blog.csdn.net/claroja/article/details/70841382
subplot()是将整个figure均等分割,而axes()则可以在figure上画图。
"""axes的使用""" import matplotlib.pyplot as plt
import numpy as np # 创建数据
dt = 0.001
t = np.arange(0.0, 10.0, dt)
r = np.exp(-t[:1000]/0.05) # impulse response
x = np.random.randn(len(t)) # 从标准正太分布中返回len(t)个随机数
s = np.convolve(x, r)[:len(x)] * dt # colored noise
# 默认主轴图axes是subplot(111)
plt.plot(t, s)
plt.axis([0, 1, 1.1*np.amin(s), 2*np.amax(s)])
plt.xlabel('time(s)')
plt.ylabel('current(nA)')
plt.title('Gaussian colored noise')
# 内嵌图
a = plt.axes([.65, .6, .2, .2], facecolor='y')
# Add an axes to the figure,第一个参数是指定axes的位置和高度,[距左距离,距底距离,宽,高],都是0-1之间,按比例表示
n, bins, patches = plt.hist(s, 400, normed=1)
plt.title('probability')
plt.xticks([]) # 不显示坐标轴标签
plt.yticks([])
# 另外一个内嵌图
b = plt.axes([0.2, 0.6, .2, .2], facecolor='y')
plt.plot(t[:len(r)], r)
plt.title('Impulse response')
plt.xlim(0, 0.2)
plt.xticks([])
plt.yticks([])
plt.show()

可以通过clf()清空当前的图板(figure),通过cla()来清理当前的轴(axes)。你需要特别注意的是记得使用close()关闭当前figure画板

matplotlib 的 subplot, axes and axis的更多相关文章
- Matplotlib中figure、subplot、axes、axis的区别
参考链接:https://blog.csdn.net/JasonZhu_csdn/article/details/85860963 画图板/画布: 这是一个基础载体,类似实际的画图板,用pyplot. ...
- matplotlib中subplot的使用
#plt.subplot的使用 import numpy as npimport matplotlib.pyplot as pltx=[1,2,3,4]y=[5,4,3,2]plt.subplot(2 ...
- python下matplotlib的subplot的多图显示位置的问题
1.说明 1.1 多图: 221,222 212 ------------附最后讲解,这下更清楚了吧,取个名字:颠倒一下--- 1.2 多图 211 223,224 ------------附最后讲解 ...
- matplotlib中subplot的各参数的作用
subplot(a,b,c)中a代表所画图形的行数 b代表所画图形的列数 c代表所画图形的序号. plt.figure(facecolor='w', figsize=(9, 10)) plt.subp ...
- 【Matplotlib-01】Python 绘图库 Matplotlib 入门教程
环境: Windows10 python3.6.4 numpy1.14.1 matplotlib2.1.2 工具:Cmder 目录: 1.线性图 2.散点图 3.饼状图 4.条形图 5.直方图 例1: ...
- matplotlib的读书笔记
matplotlib绘图总结 本文作为学习过程中对matplotlib一些常用知识点的整理,方便查找. 类MATLAB API 最简单的入门是从类 MATLAB API 开始,它被设计成兼容 MA ...
- matplotlib绘图的基本操作
转自:Laumians博客园 更简明易懂看Matplotlib Python 画图教程 (莫烦Python)_演讲•公开课_科技_bilibili_哔哩哔哩 https://www.bilibili. ...
- 数据分析之Matplotlib和机器学习基础
一.Matplotlib基础知识 Matplotlib 是一个 Python 的 2D绘图库,它以各种硬拷贝格式和跨平台的交互式环境生成出版质量级别的图形. 通过 Matplotlib,开发者可以仅需 ...
- matplotlib绘图总结
本文作为学习过程中对matplotlib一些常用知识点的整理,方便查找. 类MATLAB API 最简单的入门是从类 MATLAB API 开始,它被设计成兼容 MATLAB 绘图函数. from p ...
随机推荐
- 通过http输出流的方式从将html写入到Excel
private void HtmlResponseToExecl() { //将数据(html)导入到Excel中 Response.Charset = "gb2312"; Res ...
- jira集成fisheye代码深度查看工具安装绿色版
软件介绍: Fisheye 是一个源代码库深度查看软件,它可以挖掘源代码库中的有用信息,呈现在Web浏览器界面上,Fisheye优点: 1) Fisheye是一个基于Web的代码管理系统,可以与SVN ...
- 关于Unity中的几何体,材质和FBX模型
一.创建几何体的类型 1: 创建平面 Plane;2: 创建立方体 Cube;3: 创建球体 Sphere;4: 创建胶囊体 Capsule;5: 创建圆柱体 Cylinder;6: 3D文字 3D ...
- linux -- Ubuntu修改静态IP地址重启后无法上网的解决
ubuntu设置静态IP地址后,上不了网 文章中也提到,如果是在/etc/resolv.conf添加DNS,由于Ubuntu 有一个 resolvconf 服务,如果重启它,那么 /etc/resol ...
- 【BZOJ4518】[Sdoi2016]征途 斜率优化
[BZOJ4518][Sdoi2016]征途 Description Pine开始了从S地到T地的征途. 从S地到T地的路可以划分成n段,相邻两段路的分界点设有休息站. Pine计划用m天到达T地.除 ...
- Spring的AOP-----HelloWord
这里就一个计算器开发为例1搭建环境-搭配好Spring的AOP开发环境导入以下这些包:2建立好核心处理模块的类ArithmeticCalculator: package com.jeremy.spri ...
- Code Forces 645C Enduring Exodus
C. Enduring Exodus time limit per test2 seconds memory limit per test256 megabytes inputstandard inp ...
- 【转载】Java并发编程:volatile关键字解析
http://www.cnblogs.com/dolphin0520/p/3920373.html
- 让网站全面支持v4/v6 HTTP、HTTPS、HTTP/2最简单方法是增加Nginx反向代理服务器
bg6cq/nginx-install: nginx install script https://github.com/bg6cq/nginx-install [原创]step-by-step in ...
- 移除 URL 中的 index.php
w 将.htaaccess 放至该站点根目录. http://codeigniter.org.cn/user_guide/general/urls.html 如果你的 Apache 服务器启用了 mo ...