Py中pyplot之subplot例子【转载】
转自:https://matplotlib.org/api/_as_gen/matplotlib.pyplot.subplot.html
1.有NaN的余弦图subplot
import numpy as np
import matplotlib.pyplot as plt t = np.arange(0.0, 1.0 + 0.01, 0.01)
s = np.cos(2 * 2*np.pi * t)
t[41:60] = np.nan plt.subplot(2, 1, 1)#两行一列的子图,目前在第一个位置画。
plt.plot(t, s, '-', lw=2) plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('A sine wave with a gap of NaNs between 0.4 and 0.6')
plt.grid(True) plt.subplot(2, 1, 2)#在第二位时
t[0] = np.nan
t[-1] = np.nan#最后一个也是NaN
plt.plot(t, s, '-', lw=2)
plt.title('Also with NaN in first and last point') plt.xlabel('time (s)')
plt.ylabel('more nans')
plt.grid(True) #plt.tight_layout()没有这一句的话,第二张图的标题和第一张图的xlabel会重合。
plt.show()

去掉布局的注释:

2.图例legend
ax.legend(…., loc=3) 具体对应位置如下图

3.subplots函数返回
Returns
-------
fig : :class:`matplotlib.figure.Figure` object ax : Axes object or array of Axes objects. ax can be either a single :class:`matplotlib.axes.Axes` object or an
array of Axes objects if more than one subplot was created. The
dimensions of the resulting array can be controlled with the squeeze
keyword, see above.
4.subplot函数
def subplot(*args, **kwargs):
"""
Return a subplot axes positioned by the given grid definition. Typical call signature:: subplot(nrows, ncols, plot_number)
Py中pyplot之subplot例子【转载】的更多相关文章
- Py中re.sub学习【转载】
转自:https://www.crifan.com/python_re_sub_detailed_introduction/ //这个网址讲的不错. 1.re.sub的功能 re是regular ex ...
- Py中的矩阵乘法【转载】
转自:https://blog.csdn.net/cqk0100/article/details/76221749 1.总结 对于array对象,*和np.multiply函数代表的是数量积,如果希望 ...
- [django]urls.py 中重定向
Django 1.5 有时候需要对一个链接直接重定向,比如首页啥的重定向到一个内容页等等,在views.py 中可以设定,如果没有参数啥的在urls.py 中设定更加方面 from django.vi ...
- easyui datagrid 禁止选中行 EF的增删改查(转载) C# 获取用户IP地址(转载) MVC EF 执行SQL语句(转载) 在EF中执行SQL语句(转载) EF中使用SQL语句或存储过程 .net MVC使用Session验证用户登录 PowerDesigner 参照完整性约束(转载)
easyui datagrid 禁止选中行 没有找到可以直接禁止的属性,但是找到两个间接禁止的方式. 方式一: //onClickRow: function (rowIndex, rowData) ...
- OpenFOAM 中边界条件的设定【转载】
转载自:http://blog.sina.com.cn/s/blog_a0b4201d0102v7jt.html 用习惯了FLUENT的操作界面,再使用OpenFOAM就会觉得非常繁琐.遇到的第一个问 ...
- Python中super的用法【转载】
Python中super的用法[转载] 转载dxk_093812 最后发布于2019-02-17 20:12:18 阅读数 1143 收藏 展开 转载自 Python面向对象中super用法与MRO ...
- py中变量名的“秘密”
今天突然脑子发抽,想到py里有没有指针这个概念,于是我马上google.baidu了一波,发现网上大多都在说py.java.c#这类纯面向对象的编程语言用对象的概念能完全替代指针.那么问题来了,没有指 ...
- python调用py中rar的路径问题。
1.python调用py,在py中的os.getcwd()获取的不是py的路径,可以通过os.path.split(os.path.realpath(__file__))[0]来获取py的路径. 2. ...
- Django 中 如何使用 settings.py 中的常量
在用django 框架开发 python web 程序的时候 , 在模板页面经常会用到 settings.py 中设置的常量,比如MEDIA_URL, 我尝试过在模板页面用类似如下的方式 程序代码 { ...
随机推荐
- 用layer插件实现tp3.2的分页
主要需要用到 /layer/layer.js 这个, 现在一个tp前端视图/article/index.html <!DOCTYPE html> <html lang=" ...
- C数组&结构体&联合体快速初始化
背景 C89标准规定初始化语句的元素以固定顺序出现,该顺序即待初始化数组或结构体元素的定义顺序. C99标准新增指定初始化(Designated Initializer),即可按照任意顺序对数组某些元 ...
- Androidの矢量图形之VectorDrawable研究
5.0以上支持VectorDrawable了,可以创建vector的xml资源文件.vector其实就使用来绘制矢量图形的. 看一个例子: <?xml version="1.0&quo ...
- sencha touch tpl 实现按钮功能
js如下: Ext.define('app.view.message.Info', { alternateClassName: 'messageInfo', extend: 'Ext.Containe ...
- [原]Failed to load SELinux policy. System Freezing ----redhat7or CentOS7 bug
重启rhel7或者centos7 启动界面按 e 在启动项后面加上enforcing=0 Ctrl+x 运行修改后的grub 进入系统 编辑保存/etc/selinux/config 重启
- 生产环境mysql的参数设置不一样,好好的程序,又出错
一.概述 报错信息如下: org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: c ...
- 【CF888G】Xor-MST Trie树(模拟最小生成树)
[CF888G]Xor-MST 题意:给你一张n个点的完全图,每个点有一个权值ai,i到j的边权使ai^aj,求这张图的最小生成树. n<=200000,ai<2^30 题解:学到了求最小 ...
- ios三张图片组合一张
- (UIImage *)addImage:(UIImage *)image1 toImage:(UIImage *)image2 { UIGraphicsBeginImageContext(imag ...
- 有哪些sql优化工具
https://www.oschina.net/p/soar-xiaomi https://www.oschina.net/news/101034/xiaomi-opensource-soar SOA ...
- [转][darkbaby]任天堂传——失落的泰坦王朝(下)
即使是日本业界人士也对1999年发生的“口袋妖怪所有权风波”知之甚少,实际上这个事件的结局足以改变游戏产业未来数十年的势力图,山内溥凭借着个人的睿智让任天堂再次渡过了命运的暗礁,而另一颗曾经炙手可热的 ...