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 的使用的更多相关文章

  1. Matlab学习笔记 figure函数

    Matlab学习笔记 figure函数 matlab中的 figure 命令,能够创建一个用来显示图形输出的一个窗口对象.每一个这样的窗口都有一些属性,例如窗口的尺寸.位置,等等.下面一一介绍它们. ...

  2. html5标签figure、figcaption

    figure.figcaption,这俩个标签都是定义图文的 常常用到一种图片列表,图片+标题或者图片+标题+简单描述.以前的常规写法: <li> <img src="te ...

  3. figure元素

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. Key Figure中的Aggregation决定了DSO/CUBE转换规则中的Aggregation合计方式

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  5. Key Figure、Exception Aggreagion、Non-Cumulative KeyFigure

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  6. [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 ...

  7. matlab figure 窗口最大化

    http://blog.163.com/yinhexiwen@126/blog/static/6404826620122942057214/ % figure 窗口最大化,坐标轴也随着窗口变大而相应变 ...

  8. matlab figure 论文级别绘图

    1.将figure调整为最大: figure;set(gcf,'outerposition',get(0,'screensize')); 2.获得figure中的大小 [x,y] = ginput 3 ...

  9. latex figure \label 放在\caption 后

    http://www.cnblogs.com/loca/p/4264686.html latex figure \label 放在\caption 后,否则将显示\section 或者\subsect ...

  10. [转] matlab figure最大化

    http://blog.163.com/yinhexiwen@126/blog/static/6404826620122942057214/ % figure 窗口最大化,坐标轴也随着窗口变大而相应变 ...

随机推荐

  1. 一次单体测试的采坑--MatcherAssert.assertThat---org.hamcrest 和org.mockito

    单体测试测试环境ci上报这个错, 本地没问题. org.hamcrest.Matcher.describeMismatch(Ljava/lang/Object;Lorg/hamcrest/Descri ...

  2. 浅拷贝(Shallow Copy) VS 深拷贝(Deep Copy)

    首先,深拷贝和浅拷贝针对的是对象类型(对象,数组,函数) 浅拷贝指的是只是拷贝了对象的引用地址,彼此之间高耦合,一个改变,另一个可能也随之改变: 深拷贝是指只是完整的将变量的值拷贝过来,是一个新的对象 ...

  3. jQuery的事件处理

    一.页面加载响应事件 $(document).ready()方法,获取文档就绪的时候.他极大地提高了Web相应速度.虽然该方法可以代替传统的window.onload()方法,但是两者之间仍然有差别. ...

  4. Vue接口异常时处理

    一般接口只会对后台返回的json状态进行判断处理,当后台异常时,我们可以使用catch来对这些异常进行同样的报错处理. 例如: 上面显示代码例子中test为一个接口,json为后台正常返回的数据对象, ...

  5. 开启ucosii的移植之旅

    开启ucosii的移植之旅: 4.6.1.移植和硬件平台的关系 (1)只要是cortex-m3内核内核的soc移植差异都不大. 同内核同soc的不同开发板移植差异都不大. 不同内核的开发板移植难度大, ...

  6. python3 while-else和for-else语法

    while-else: while判断条件不成立时,执行else语句: 语法: while 判断条件: 语句1.... else: 语句2.... i初始值为2,i>0成立,则执行while语句 ...

  7. SNOI 2019 字符串

    SNOI 2019 字符串 题目 题解: 解法一: 记一个数组\(f\),\(f[i]=\min_j\ s[j]\neq s[j+1] (j\geq i)\),直接sort即可,复杂度\(O(nlog ...

  8. Python菜鸟快乐游戏编程_pygame(3)

    Python菜鸟快乐游戏编程_pygame(博主录制,2K分辨率,超高清) https://study.163.com/course/courseMain.htm?courseId=100618802 ...

  9. crm 一级菜单排序,二级菜单选中并且展开,非菜单权限的归属,权限粒度控制到按钮级别

    排序 /rbac/templatetags/rbac.py from django import template from django.conf import settings import re ...

  10. unicorn与nginx通讯--[ruby unix socket]

    [龍昌博客] http://www.xefan.com/archives/84146.html unicorn是如何与nginx通讯的——介绍ruby中的unix socket Ruby 应用服务典型 ...