面向对象
面向对象写程序, 是一直在对一些对象作一些操作.
总的来说, Figure 类相当于画板, Axes 相当于画纸
figure : Figure The Figure instance returned will also be passed to newfiguremanager in the backends, which allows to hook custom Figure classes into the pyplot interface. Additional kwargs will be passed to the Figure init function.
plt.figure()返回一个 matplotlib.figure.Figure, 它是一个类,
The top level container for all the plot elements. 它是所有 plot 元素的最上级容器
plt.subplot() 返回一个 Axes 类
The Axes contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. Axes 包含大部分 figure 元素, 比如 Axis, Tick, Line2D, Text, Polygon, 等等, 以及 sets the coordinate system.
示例
import numpy as np |
Results