matplotlib 初步介绍

matplotlib官方文档

概念

matplotlib 初步介绍_第1张图片
基本图

figure

The whole figure. The figure keeps track of all the child Axes, a smattering of 'special' artists (titles, figure legends, etc), and the canvas.

figure 包含子axes, 特殊的atrists和canvas
创建figure的方法

fig = plt.figure()  # an empty figure with no axes
fig.suptitle('No axes on this figure')  # Add a title so we know which it is

fig, ax_lst = plt.subplots(2, 2)  # a figure with a 2x2 grid of Axes
matplotlib 初步介绍_第2张图片
没有axes
matplotlib 初步介绍_第3张图片
2x2 的 axes

Axes

This is what you think of as 'a plot', it is the region of the image with the data space. A given figure can contain many Axes, but a given Axes object can only be in one Figure.

数据区域,一个Axes只能在一个figure里面

set_xlim() # x轴范围
set_ylim()
set_title()
set_xlabels() # x轴标签
set_ylabels()

Axes 其他方法

Axis

Artist

Basically everything you can see on the figure is an artist (even the Figure, Axes, and Axis objects). This includes Text objects, Line2D objects, collection objects, Patch objects ... (you get the idea). When the figure is rendered, all of the artists are drawn to the canvas. Most Artists are tied to an Axes; such an Artist cannot be shared by multiple Axes, or moved from one to another.

所有东西都是Artist

你可能感兴趣的:(matplotlib 初步介绍)