Figure, Axes, Axis, and Subplot

axes_vs_axis

As we can see, the Figure is a top-level container that includes “Axes” and “Axis”.“Axes” is the area where plots appear, while “Axis” is the axis of the plots.

axes-subplots-axis

Axes is set up by calling subplot, so “Axes” and “Subplot” are synonymous in many cases.

Subplot vs. Axes

Subplot can arrange grid. plt.subplot(row, col, index) return me an area where occupies part of the Figure. For example:

plt.subplot(2, 1, 1)
plt.subplot(2, 1, 2)

Thes will give me two subplots:

subplot_result

I can think that they are both in a 2x1 matrix, one is at index 1, another is at index 2, or subplot() divides the figure into seperate parts. I can add plots in 2 subplots.

Similarly:

fig.add_subplot(2, 2, 1)
fig.subplot(2, 2, 2)
fig.subplot(2, 2, 3)
fig.subplot(2, 2, 4)

subplots_result2

Axes is more flexible.

fig.add_axes(0.1, 0.1, 0.8, 0.8)
fig.add_axes(0.2, 0.2, 0.3, 0.3)

This will gives me:

axes_result

Reference:

  1. “Parts of a Figure”, matplotlib.org
  2. Anatomy of a “Plot”, jupyter.org
  3. “python matplotlib中axes与axis的区别?”, 禹洋
  4. “Matplotlib: plotting”, Nicolas Rougier, Mike Müller, Gaël Varoquaux