转自: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例子【转载】的更多相关文章

  1. Py中re.sub学习【转载】

    转自:https://www.crifan.com/python_re_sub_detailed_introduction/ //这个网址讲的不错. 1.re.sub的功能 re是regular ex ...

  2. Py中的矩阵乘法【转载】

    转自:https://blog.csdn.net/cqk0100/article/details/76221749 1.总结 对于array对象,*和np.multiply函数代表的是数量积,如果希望 ...

  3. [django]urls.py 中重定向

    Django 1.5 有时候需要对一个链接直接重定向,比如首页啥的重定向到一个内容页等等,在views.py 中可以设定,如果没有参数啥的在urls.py 中设定更加方面 from django.vi ...

  4. easyui datagrid 禁止选中行 EF的增删改查(转载) C# 获取用户IP地址(转载) MVC EF 执行SQL语句(转载) 在EF中执行SQL语句(转载) EF中使用SQL语句或存储过程 .net MVC使用Session验证用户登录 PowerDesigner 参照完整性约束(转载)

    easyui datagrid 禁止选中行   没有找到可以直接禁止的属性,但是找到两个间接禁止的方式. 方式一: //onClickRow: function (rowIndex, rowData) ...

  5. OpenFOAM 中边界条件的设定【转载】

    转载自:http://blog.sina.com.cn/s/blog_a0b4201d0102v7jt.html 用习惯了FLUENT的操作界面,再使用OpenFOAM就会觉得非常繁琐.遇到的第一个问 ...

  6. Python中super的用法【转载】

    Python中super的用法[转载] 转载dxk_093812 最后发布于2019-02-17 20:12:18 阅读数 1143  收藏 展开 转载自 Python面向对象中super用法与MRO ...

  7. py中变量名的“秘密”

    今天突然脑子发抽,想到py里有没有指针这个概念,于是我马上google.baidu了一波,发现网上大多都在说py.java.c#这类纯面向对象的编程语言用对象的概念能完全替代指针.那么问题来了,没有指 ...

  8. python调用py中rar的路径问题。

    1.python调用py,在py中的os.getcwd()获取的不是py的路径,可以通过os.path.split(os.path.realpath(__file__))[0]来获取py的路径. 2. ...

  9. Django 中 如何使用 settings.py 中的常量

    在用django 框架开发 python web 程序的时候 , 在模板页面经常会用到 settings.py 中设置的常量,比如MEDIA_URL, 我尝试过在模板页面用类似如下的方式 程序代码 { ...

随机推荐

  1. 常见微信小程序开发工具

    图标: 1.iconfont图标库:http://www.iconfont.cn/home/index?spm=a313x.7781069.1998910419.2

  2. 【python】解决No module named _sqlite3的问题

    环境版本说明: centos 7 python3.6.4 django 2.0 在创建django项目时候.报错以下信息 详细错误信息如下: 原因: 未安装sqlite 模块 解决: 1 安装 sql ...

  3. 有关xml中的xmlns

    1. xmlns "xmlns"是XHTML namespace的缩写,叫做"名字空间"声明.名字空间是什么作用呢?我的理解是:由于xml允许你自己定义自己的标 ...

  4. 认识OpenStack中的flatnetwork

    目录 [隐藏] 1 Understanding FlatNetworking 1.1 FlatNetworking 1.1.1 Single Adapter, All in one setup 1.1 ...

  5. 【BZOJ1210】[HNOI2004]邮递员 插头DP+高精度

    [BZOJ1210][HNOI2004]邮递员 Description Smith在P市的邮政局工作,他每天的工作是从邮局出发,到自己所管辖的所有邮筒取信件,然后带回邮局.他所管辖的邮筒非常巧地排成了 ...

  6. POJ-放苹果(DP)

    放苹果 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 29074 Accepted: 18376 Description 把M个 ...

  7. ubuntu16.04安装 lrzsz

    编译安装 root 账号登陆后,依次执行以下命令: tar zxvf lrzsz-.tar.gz cd lrzsz- ./configure make make install 上面安装过程默认把ls ...

  8. ubuntu16.04下安装opencv3.1.0

    1.安装依赖项 sudo apt--dev pkg-config libavcodec-dev libavformat-dev libswscale-dev 可选的 sudo apt--dev lib ...

  9. POJ 3254 - Corn Fields - [状压DP水题]

    题目链接:http://poj.org/problem?id=3254 Time Limit: 2000MS Memory Limit: 65536K Description Farmer John ...

  10. python3学习笔记(8)_sorted

    # python学习笔记 2017/07/13 # !/usr/bin/env python3 # -*- coding:utf-8 -*- #python 内置sorted()函数 可以对list进 ...