figure 的使用
1.figure语法及操作
(1)figure语法说明
figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True)
num:图像编号或名称,数字为编号 ,字符串为名称
figsize:指定figure的宽和高,单位为英寸;
dpi参数指定绘图对象的分辨率,即每英寸多少个像素,缺省值为80 1英寸等于2.5cm,A4纸是 21*30cm的纸张
facecolor:背景颜色
edgecolor:边框颜色
frameon:是否显示边框
(2)例子:
import matplotlib.pyplot as plt
创建自定义图像
fig=plt.figure(figsize=(4,3),facecolor='blue')
plt.show()
2.subplot创建单个子图
(1) subplot语法
subplot(nrows,ncols,sharex,sharey,subplot_kw,**fig_kw)

subplot可以规划figure划分为n个子图,但每条subplot命令只会创建一个子图 ,参考下面例子。
(2)例子
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 100)
#作图1
plt.subplot(221)
plt.plot(x, x)
#作图2
plt.subplot(222)
plt.plot(x, -x)
#作图3
plt.subplot(223)
plt.plot(x, x ** 2)
plt.grid(color='r', linestyle='--', linewidth=1,alpha=0.3)
#作图4
plt.subplot(224)
plt.plot(x, np.log(x))
plt.show()

3.subplots创建多个子图
(1)subplots语法
subplots参数与subplots相似
(2)例子
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 100)
#划分子图
fig,axes=plt.subplots(2,2)
ax1=axes[0,0]
ax2=axes[0,1]
ax3=axes[1,0]
ax4=axes[1,1]
#作图1
ax1.plot(x, x)
#作图2
ax2.plot(x, -x)
#作图3
ax3.plot(x, x ** 2)
ax3.grid(color='r', linestyle='--', linewidth=1,alpha=0.3)
#作图4
ax4.plot(x, np.log(x))
plt.show()

4.面向对象API:add_subplots与add_axes新增子图或区域
add_subplot与add_axes都是面对象figure编程的,pyplot api中没有此命令
(1)add_subplot新增子图
add_subplot的参数与subplots的相似
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 100)
#新建figure对象
fig=plt.figure()
#新建子图1
ax1=fig.add_subplot(2,2,1)
ax1.plot(x, x)
#新建子图3
ax3=fig.add_subplot(2,2,3)
ax3.plot(x, x ** 2)
ax3.grid(color='r', linestyle='--', linewidth=1,alpha=0.3)
#新建子图4
ax4=fig.add_subplot(2,2,4)
ax4.plot(x, np.log(x))
plt.show()

figure 的使用的更多相关文章
- Matlab学习笔记 figure函数
Matlab学习笔记 figure函数 matlab中的 figure 命令,能够创建一个用来显示图形输出的一个窗口对象.每一个这样的窗口都有一些属性,例如窗口的尺寸.位置,等等.下面一一介绍它们. ...
- html5标签figure、figcaption
figure.figcaption,这俩个标签都是定义图文的 常常用到一种图片列表,图片+标题或者图片+标题+简单描述.以前的常规写法: <li> <img src="te ...
- figure元素
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Key Figure中的Aggregation决定了DSO/CUBE转换规则中的Aggregation合计方式
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- Key Figure、Exception Aggreagion、Non-Cumulative KeyFigure
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- [Chapter 3 Process]Practice 3.12 Including the initial parent process, how many processes are created by the program shown in Figure 3.32?
3.12 Including the initial parent process, how many processes are created by the program shown in Fi ...
- matlab figure 窗口最大化
http://blog.163.com/yinhexiwen@126/blog/static/6404826620122942057214/ % figure 窗口最大化,坐标轴也随着窗口变大而相应变 ...
- matlab figure 论文级别绘图
1.将figure调整为最大: figure;set(gcf,'outerposition',get(0,'screensize')); 2.获得figure中的大小 [x,y] = ginput 3 ...
- latex figure \label 放在\caption 后
http://www.cnblogs.com/loca/p/4264686.html latex figure \label 放在\caption 后,否则将显示\section 或者\subsect ...
- [转] matlab figure最大化
http://blog.163.com/yinhexiwen@126/blog/static/6404826620122942057214/ % figure 窗口最大化,坐标轴也随着窗口变大而相应变 ...
随机推荐
- Java 异常体系(美团面试)
Java把异常作为一种类,当做对象来处理.所有异常类的基类是Throwable类,两大子类分别是Error和Exception. 系统错误由Java虚拟机抛出,用Error类表示.Error类描述的是 ...
- 时间通用类 datetime
/// <summary> /// 时间通用类 /// </summary> public class DateTimeGeneral { /// <summary> ...
- Spring Boot 2.x 编写 RESTful API (一) RESTful API 介绍 & RestController
用Spring Boot编写RESTful API 学习笔记 RESTful API 介绍 REST 是 Representational State Transfer 的缩写 所有的东西都是资源,所 ...
- Android技术文章收集
Android高工必备技能! 我的 Android 开发实战经验总结 Android开发在路上:少去踩坑,多走捷径 //微信 微信Android客户端架构演进之路 微信Android版智能心跳方案 / ...
- Shell 简单构建 Node web服务器
.git bash 执行代码生成: ./makeJs.sh 生成文件如下: 访问:http://127.0.0.1:3030/index.html makeJs.sh 代码如下: #create m ...
- 「洛谷3338」「ZJOI2014」力【FFT】
题目链接 [BZOJ] [洛谷] 题解 首先我们需要对这个式子进行化简,否则对着这么大一坨东西只能暴力... \[F_i=\sum_{j<i} \frac{q_iq_j}{(i-j)^2}-\s ...
- 「CF#554 div2」题解
A 水题一道. 题目的大致意思就是:给你两个集合,求集合间有多少数对和是奇数. 题解,开\(4\)个桶后,求一个\(min\)就可以了. #include <bits/stdc++.h> ...
- Mysql 查询当月时间数据
SELECTDATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(t.transactiontime, '%Y%m'),t.*FROM ttransactions t ...
- redis基础知识思维导图
看到一张redis的基础知识思维导图,比较清晰, 但是没有标明来源,希望知道的给个地址,我也好说明来源 图大小有1M多.在博客上看比较模糊,可以先下载下来查看,或者在浏览器新标签中打开图片查看,就比较 ...
- Python基础和原反补码及表达式
基础语法 1.注释 “#”标注的文件 2.数字 整数,不区分long和int 进制0xa.0o10.0b10 bool,2个值True.False 浮点数 1.2.3.1314.-0.12.1.46e ...