11"""
22=====================================
3- Arranging multiple * Axes* in a Figure
3+ Arranging multiple Axes in a Figure
44=====================================
55
6- Often more than one * Axes* is wanted on a figure at a time, usually
6+ Often more than one Axes is wanted on a figure at a time, usually
77organized into a regular grid. Matplotlib has a variety of tools for
8- working with grids of * Axes* that have evolved over the history of the library.
8+ working with grids of Axes that have evolved over the history of the library.
99Here we will discuss the tools we think users should use most often, the tools
10- that underpin how * Axes* are organized, and mention some of the older tools.
10+ that underpin how Axes are organized, and mention some of the older tools.
1111
1212.. note::
1313
14- Matplotlib uses *Axes* to refer to an *Artist* that contains plotting
15- *Artists* and the x- and y-*Axis*. Another term that is often used is
16- "subplot", which refers to an *Axes* that is arranged in a grid.
17- See `<figure_parts>`_ for more details of Matplotlib terminology .
14+ Matplotlib uses *Axes* to refer to the drawing area that contains
15+ data, x- and y-axis, ticks, labels, title, etc. See <figure_parts>_ for
16+ more details. Another term that is often used is "subplot", which refers
17+ to an Axes that is in a grid with other Axes objects .
1818
1919Overview
2020========
2121
22- Create grid-shaped combinations of * Axes*
23- -----------------------------------------
22+ Create grid-shaped combinations of Axes
23+ ---------------------------------------
2424
2525`~matplotlib.pyplot.subplots`
26- The primary function used to create figures and a grid of * Axes* . It
27- creates and places all * Axes* on the figure at once, and returns an
28- object array with handles for the * Axes* in the grid. See
26+ The primary function used to create figures and a grid of Axes. It
27+ creates and places all Axes on the figure at once, and returns an
28+ object array with handles for the Axes in the grid. See
2929 `.Figure.subplots`.
3030
3131or
3232
3333`~matplotlib.pyplot.subplot_mosaic`
34- A simple way to create figures and a grid of * Axes* , with the added
35- flexibility that * Axes* can also span rows or columns. The * Axes*
34+ A simple way to create figures and a grid of Axes, with the added
35+ flexibility that Axes can also span rows or columns. The Axes
3636 are returned in a labelled dictionary instead of an array. See also
3737 `.Figure.subplot_mosaic` and :doc:`/tutorials/provisional/mosaic`.
3838
39- Sometimes it is natural to have more than one distinct group of * Axes* grids,
39+ Sometimes it is natural to have more than one distinct group of Axes grids,
4040in which case Matplotlib has the concept of `~.figure.SubFigure`:
4141
4242`~matplotlib.figure.SubFigure`
5757`~matplotlib.gridspec.SubplotSpec`
5858 Specifies the location of the subplot in the given `.GridSpec`.
5959
60- Adding single * Axes* at a time
61- ------------------------------
60+ Adding single Axes at a time
61+ ----------------------------
6262
63- The above functions create all * Axes* in a single function call. It is also
64- possible to add * Axes* one at a time, and this was originally how Matplotlib
63+ The above functions create all Axes in a single function call. It is also
64+ possible to add Axes one at a time, and this was originally how Matplotlib
6565used to work. Doing so is generally less elegant and flexible, though
66- sometimes useful for interactive work or to place an * Axes* in a custom
66+ sometimes useful for interactive work or to place an Axes in a custom
6767location:
6868
6969`~matplotlib.pyplot.subplot` or `.Figure.add_subplot`
8585# Basic 2x2 grid
8686# --------------
8787#
88- # We can create a basic 2-by-2 grid of * Axes* using
88+ # We can create a basic 2-by-2 grid of Axes using
8989# :func:`~matplotlib.pyplot.subplots`. It returns a
9090# :class:`~matplotlib.figure.Figure` instance and an array of
91- # :class:`~matplotlib.axes.Axes` objects. The * Axes* objects can
92- # be used to access methods to place artists on the * Axes* ; here we
91+ # :class:`~matplotlib.axes.Axes` objects. The Axes objects can
92+ # be used to access methods to place artists on the Axes; here we
9393# use `~.Axes.annotate`, but other examples could be `~.Axes.plot`,
9494# `~.Axes.pcolormesh`, etc.
9595
108108fig .suptitle ('plt.subplots()' )
109109
110110##############################################################################
111- # We will annotate a lot of * Axes* , so lets encapsulate the annotation, rather
111+ # We will annotate a lot of Axes, so lets encapsulate the annotation, rather
112112# than having that large piece of annotation code every time we need it:
113113
114114
@@ -132,10 +132,10 @@ def annotate_axes(ax, text, fontsize=18):
132132fig .suptitle ('plt.subplot_mosaic()' )
133133
134134############################################################################
135- # * Axes* spanning rows or columns in a grid
136- # -----------------------------------------
135+ # Axes spanning rows or columns in a grid
136+ # ---------------------------------------
137137#
138- # Sometimes we want * Axes* to span rows or columns of the grid.
138+ # Sometimes we want Axes to span rows or columns of the grid.
139139# There are actually multiple ways to accomplish this, but the most
140140# convenient is probably to use `~.pyplot.subplot_mosaic` by repeating one
141141# of the keys:
@@ -171,13 +171,13 @@ def annotate_axes(ax, text, fontsize=18):
171171fig .suptitle ('plt.subplot_mosaic()' )
172172
173173############################################################################
174- # Nested * Axes* layouts
175- # ---------------------
174+ # Nested Axes layouts
175+ # -------------------
176176#
177- # Sometimes it is helpful to have two or more grids of * Axes* that
177+ # Sometimes it is helpful to have two or more grids of Axes that
178178# may not need to be related to one another. The most simple way to
179179# accomplish this is to use `.Figure.subfigures`. Note that the alignement
180- # of the subfigure layouts is independent with the * Axes* spines in each
180+ # of the subfigure layouts is independent with the Axes spines in each
181181# subfigure having independent positions. See below for a more verbose
182182# way to acheive the same effect with `~.gridspec.GridSpecFromSubplotSpec`.
183183
@@ -193,7 +193,7 @@ def annotate_axes(ax, text, fontsize=18):
193193subfigs [1 ].supylabel ('ylabel for subfigs[1]' )
194194
195195############################################################################
196- # It is also possible to nest * Axes* using `~.pyplot.subplot_mosaic` using
196+ # It is also possible to nest Axes using `~.pyplot.subplot_mosaic` using
197197# nested lists. This method does not use subfigures, like above, so lacks
198198# the ability to add per-subfigure ``suptitle`` and ``supxlabel``, etc.
199199# Rather it is a conveneince wrapper around the `~.SubplotSpec.subgridspec`
@@ -212,13 +212,13 @@ def annotate_axes(ax, text, fontsize=18):
212212# Low-level and advanced grid methods
213213# ===================================
214214#
215- # Internally, the arrangement of a grid of * Axes* is controlled by creating
215+ # Internally, the arrangement of a grid of Axes is controlled by creating
216216# instances of `~.GridSpec` and `~.SubplotSpec`. *GridSpec* defines a
217217# (possibly non-uniform) grid of cells. Indexing into the *GridSpec* returns
218218# a SubplotSpec that covers one or more grid cells, and can be used to
219- # specify the location of an * Axes* .
219+ # specify the location of an Axes.
220220#
221- # The following examples show how to use low-level methods to arrange * Axes*
221+ # The following examples show how to use low-level methods to arrange Axes
222222# using *GridSpec* objects.
223223#
224224# Basic 2x2 grid
@@ -240,12 +240,12 @@ def annotate_axes(ax, text, fontsize=18):
240240fig .suptitle ('Manually added subplots using add_gridspec' )
241241
242242##############################################################################
243- # * Axes* spanning rows or grids in a grid
244- # ---------------------------------------
243+ # Axes spanning rows or grids in a grid
244+ # -------------------------------------
245245#
246246# We can index the *spec* array using `NumPy slice syntax
247247# <https://numpy.org/doc/stable/reference/arrays.indexing.html>`_
248- # and the new * Axes* will span the slice. This would be the same
248+ # and the new Axes will span the slice. This would be the same
249249# as ``fig, axd = plt.subplot_mosaic([['ax0', 'ax0'], ['ax1', 'ax2']], ...)``:
250250
251251fig = plt .figure (figsize = (4.5 , 3.5 ), constrained_layout = True )
@@ -267,7 +267,7 @@ def annotate_axes(ax, text, fontsize=18):
267267# option is not compatible with ``constrained_layout`` or
268268# `.Figure.tight_layout` which both ignore *left* and *right* and adjust
269269# subplot sizes to fill the figure. Usually such manual placement
270- # requires iterations to make the * Axes* tick labels not overlap the * Axes* .
270+ # requires iterations to make the Axes tick labels not overlap the Axes.
271271#
272272# These spacing parameters can also be passed to `~.pyplot.subplots` and
273273# `~.pyplot.subplot_mosaic` as the *gridspec_kw* argument.
@@ -288,7 +288,7 @@ def annotate_axes(ax, text, fontsize=18):
288288# -------------------------------
289289#
290290# You can create nested layout similar to `~.Figure.subfigures` using
291- # `~.gridspec.SubplotSpec.subgridspec`. Here the * Axes* spines _are_
291+ # `~.gridspec.SubplotSpec.subgridspec`. Here the Axes spines _are_
292292# aligned.
293293#
294294# Note this is also available from the more verbose
@@ -316,7 +316,7 @@ def annotate_axes(ax, text, fontsize=18):
316316
317317###############################################################################
318318# Here's a more sophisticated example of nested *GridSpec*: We create an outer
319- # 4x4 grid with each cell containing and inner 3x3 grid of * Axes* . We outline
319+ # 4x4 grid with each cell containing and inner 3x3 grid of Axes. We outline
320320# the outer 4x4 grid by hiding appropriate spines in each of the inner 3x3
321321# grids.
322322
0 commit comments