plt.subplot()

plt.subplot(nrows, ncols, index, **kwargs)

  1. 第一个参数:*args (官网文档描述)
    Either a 3-digit integer or three separate integers describing the position of the subplot. If the three integers are nrows, ncols, and index in order, the subplot will take the index position on a grid with nrows rows and ncols columns. index starts at 1 in the upper left corner and increases to the right.
    可以使用三个整数,或者三个独立的整数来描述子图的位置信息。如果三个整数是行数、列数和索引值,子图将分布在行列的索引位置上。索引从1开始,从右上角增加到右下角。
    pos is a three digit integer, where the first digit is the number of rows, the second the number of columns, and the third the index of the subplot. i.e. fig.add_subplot(235) is the same as fig.add_subplot(2, 3, 5). Note that all integers must be less than 10 for this form to work.
    位置是由三个整型数值构成,第一个代表行数,第二个代表列数,第三个代表索引位置。举个列子:plt.subplot(2, 3, 5) 和 plt.subplot(235) 是一样一样的。需要注意的是所有的数字不能超过10。

  2. 第二个参数:projection : {None, ‘aitoff’, ‘hammer’, ‘lambert’, ‘mollweide’, ‘polar’, ‘rectilinear’, str}, optional
    The projection type of the subplot (Axes). str is the name of a costum projection, see projections. The default None results in a ‘rectilinear’ projection.
    可选参数:可以选择子图的类型,比如选择polar,就是一个极点图。默认是none就是一个线形图。

  3. 第三个参数:polar : boolean, optional
    If True, equivalent to projection=‘polar’. 如果选择true,就是一个极点图,上一个参数也能实现该功能。
    官方文档传送门:plt.subplot()

import matplotlib.pyplot as plt
import numpy as npx = np.linspace(1, 2, 2)
y1 = np.sin(x)y2 = np.cos(x)ax1 = plt.subplot(2, 2, 1, frameon = False) # 两行一列,位置是1的子图
plt.plot(x, y1, 'b--')
plt.ylabel('y1')
ax2 = plt.subplot(2, 2, 2, projection = 'polar')
plt.plot(x, y2, 'r--')
plt.ylabel('y2')
plt.xlabel('x')
plt.subplot(2, 2, 3, sharex = ax1, facecolor = 'red')
plt.plot(x, y2, 'r--')
plt.ylabel('y2')plt.show()

以上代码画图如下:

可以看到plt.subplot()可以依次画出这些子图,优点是简单明了,缺点是略显麻烦。

plt.subplot()使用方法以及参数介绍相关推荐

  1. plt.subplot()使用方法

    1. 参数介绍: plt.subplot(nrows, ncols, index) ax1 = plt.subplot(2, 2, 1, frameon = False) # 两行一列,位置是1的子图 ...

  2. 【学习笔记】28、类的方法及参数介绍

    类的方法及参数介绍 初始化方法 在类被实例化的时候,有一个方法会被自动运行,这个方法就是"__init__(self)" (前后两个下划线). 这个方法主要用于在一个对象被实例化的 ...

  3. evo使用方法及参数介绍

    evo_config evo_config用于保存配置文件,可以把自己的参数保存下来,这样就可以避免每次都输入相同的参数. 配置文件的格式为*.json. 1.生成配置文件 evo_config ge ...

  4. 指数平滑方法(一次指数平滑、二次指数平滑、三次指数平滑):理论、代码、参数 介绍(全)

    @创建于:20210324 @修改于:20210324 文章目录 特别说明 参考来源 包版本号 1.简介 2.一次指数平滑 2.1 理论介绍 2.2 代码展示 2.3 参数介绍 3. 二次指数平滑 3 ...

  5. python matplotlib在一张画布上画多个图的两种方法,plt.subplot(),plt.subplots()。

    Matplotlib在一张画布上画多个图的两种方法,plt.subplot,plt.subplots. 目录 回顾 plt.subplots()画法 plt.subplot()画法 保存 回顾 之前也 ...

  6. plt.figure、plt.subplot介绍以及绘制图中图(含代码)

    目录 1.1 plt.figure()函数语法介绍 1.2 figure实例 2.1 subplot函数及其语法说明 2.2 用subplot画多个子图 3.1 subplots函数介绍 4.1 使用 ...

  7. linux shell语法检查或者查看shell脚本执行过程的参数介绍及两种使用方法

    shell语法检查或者查看shell脚本执行过程的参数介绍及两种使用方法 一.常用参数概述: set -x 与 set +x 在liunx脚本中可用set -x就可有详细的日志输出,省的老是要echo ...

  8. 材料物理性能参数介绍及ANSYS —Workbench添加或修改仿真材料的方法

    本章将介绍静力学仿真中需要经常使用到的一些材料物理参数,这些参数在一定程度上决定了材料的力学性能.在了解材料的力学性能参数后还将继续介绍ANSYS软件添加或修改材料性能参数的方法. 一.材料物理性能参 ...

  9. bowtie 加mn标签_Bowtie2使用方法与参数详细介绍 - Public Library of Bioinformatics

    Bowtie2 使用方法与参数详细介绍 - Public Library of Bioinformatics 懒人必看 Bowtie2 -q --phred33 --sensitive --end-t ...

最新文章

  1. 三手火箭载二手飞船送四名平民上太空,马斯克负责创造历史,另一位富豪出钱买单...
  2. html5斐波那契数列,经典的斐波那契数列与arguments.callee
  3. mybatis缓存机制
  4. href 一个正则表达式的解析 ? 号解析
  5. 软件工程个人作业05
  6. python unitest框架_python单元测试框架Unitest
  7. (三)SpringBoot之配置文件详解:Properties和YAML
  8. nginx下部署showdoc
  9. ACL2021 | OntoED:利用本体表示学习实现低资源的事件抽取
  10. 写了一个字符串的二维表: TSta
  11. C语言练习题:算术入门之加减乘除(PTA)
  12. Windows11中文用户名问题:适合于新电脑
  13. 抖音养号脚本源码分享
  14. emule服务器地址列表地址
  15. LabelImg 标注 yolo 数据 环境配置和预制标签 predefined_classes.txt 的使用 详解
  16. 爬虫技术(04)神箭手爬虫field的属性
  17. 《计算之魂》第1章 毫厘千里之差——大O概念(1.4节)
  18. mysql 连续天数_mysql计算连续天数,mysql连续登录天数,连续天数统计
  19. 2019年下半年软件设计师考试上午题的英语部分原文。
  20. 黑科技之机器人外骨骼

热门文章

  1. c语言中sqrt和disc,C ++编程中的Sqrt,sqrtl和sqrtf
  2. yslow的安装方法
  3. 期刊为何发表造假论文?
  4. Python学习记录 使用tensorflow 2.8 完成猫狗识别 使用keras构建CNN神经网络
  5. 小论文,插入脚注(项目名称,作者简介)的方法!
  6. 连续两届世界杯与冠军同行 网易传媒创造内容赛道卫冕传奇
  7. 【MMD】个人记录向
  8. mysql内幕微盘_MySQL核心内幕(祝定泽、张海、黄建昌) PDF 扫描版[29M]
  9. 什么是边缘服务器?边缘计算的未来如何?
  10. 【博主已解决】win10系统wlan消失 网络适配器出现黄色感叹号(代码56)