|
28 | 28 | # area where points can be specified in terms of x-y coordinates (or theta-r
|
29 | 29 | # in a polar plot, x-y-z in a 3D plot, etc.). The simplest way of
|
30 | 30 | # creating a Figure with an Axes is using `.pyplot.subplots`. We can then use
|
31 |
| -# `.Axes.plot` to draw some data on the Axes: |
| 31 | +# `.Axes.plot` to draw some data on the Axes, and `~.pyplot.show` to display |
| 32 | +# the figure: |
32 | 33 |
|
33 |
| -fig, ax = plt.subplots() # Create a figure containing a single Axes. |
| 34 | +fig, ax = plt.subplots() # Create a figure containing a single Axes. |
34 | 35 | ax.plot([1, 2, 3, 4], [1, 4, 2, 3]) # Plot some data on the Axes.
|
| 36 | +plt.show() # Show the figure. |
35 | 37 |
|
36 | 38 | # %%
|
37 | 39 | #
|
38 |
| -# Note that to get this Figure to display, you may have to call ``plt.show()``, |
39 |
| -# depending on your backend. For more details of Figures and backends, see |
40 |
| -# :ref:`figure-intro`. |
| 40 | +# Depending on the environment you are working in, ``plt.show()`` can be left |
| 41 | +# out. - This is for example the case with Jupyter notebooks, which |
| 42 | +# automatically show all figures created in a code cell. |
41 | 43 | #
|
42 | 44 | # .. _figure_parts:
|
43 | 45 | #
|
|
53 | 55 | #
|
54 | 56 | # The **whole** figure. The Figure keeps
|
55 | 57 | # track of all the child :class:`~matplotlib.axes.Axes`, a group of
|
56 |
| -# 'special' Artists (titles, figure legends, colorbars, etc), and |
| 58 | +# 'special' Artists (titles, figure legends, colorbars, etc.), and |
57 | 59 | # even nested subfigures.
|
58 | 60 | #
|
59 |
| -# The easiest way to create a new Figure is with pyplot:: |
| 61 | +# Typically, you'll create a new Figure through one of the following |
| 62 | +# functions:: |
60 | 63 | #
|
61 |
| -# fig = plt.figure() # an empty figure with no Axes |
62 |
| -# fig, ax = plt.subplots() # a figure with a single Axes |
| 64 | +# fig = plt.figure() # an empty figure with no Axes |
| 65 | +# fig, ax = plt.subplots() # a figure with a single Axes |
63 | 66 | # fig, axs = plt.subplots(2, 2) # a figure with a 2x2 grid of Axes
|
64 | 67 | # # a figure with one Axes on the left, and two on the right:
|
65 | 68 | # fig, axs = plt.subplot_mosaic([['left', 'right_top'],
|
66 | 69 | # ['left', 'right_bottom']])
|
67 | 70 | #
|
68 |
| -# It is often convenient to create the Axes together with the Figure, but you |
69 |
| -# can also manually add Axes later on. Note that many |
70 |
| -# :ref:`Matplotlib backends <backends>` support zooming and |
71 |
| -# panning on figure windows. |
| 71 | +# `~.pyplot.subplots()` and `~.pyplot.subplot_mosaic` are convenience functions |
| 72 | +# that additionally create Axes objects inside the Figure, but you can also |
| 73 | +# manually add Axes later on. |
72 | 74 | #
|
73 |
| -# For more on Figures, see :ref:`figure-intro`. |
| 75 | +# For more on Figures, including panning and zooming, see :ref:`figure-intro`. |
74 | 76 | #
|
75 | 77 | # :class:`~matplotlib.axes.Axes`
|
76 | 78 | # ------------------------------
|
|
85 | 87 | # :meth:`~matplotlib.axes.Axes.set_xlabel`), and a y-label set via
|
86 | 88 | # :meth:`~matplotlib.axes.Axes.set_ylabel`).
|
87 | 89 | #
|
88 |
| -# The :class:`~.axes.Axes` class and its member functions are the primary |
89 |
| -# entry point to working with the OOP interface, and have most of the |
90 |
| -# plotting methods defined on them (e.g. ``ax.plot()``, shown above, uses |
91 |
| -# the `~.Axes.plot` method) |
| 90 | +# The `~.axes.Axes` methods are the primary interface for configuring |
| 91 | +# most parts of your plot (adding data, controlling axis scales and |
| 92 | +# limits, adding labels etc.). |
92 | 93 | #
|
93 | 94 | # :class:`~matplotlib.axis.Axis`
|
94 | 95 | # ------------------------------
|
|
0 commit comments