Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d356c2

Browse files
committed
DOC: organize figure API
1 parent 14a0c5b commit 8d356c2

File tree

11 files changed

+356
-31
lines changed

11 files changed

+356
-31
lines changed

doc/api/figure_api.rst

Lines changed: 316 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,319 @@
55
.. currentmodule:: matplotlib.figure
66

77
.. automodule:: matplotlib.figure
8-
:members:
9-
:inherited-members:
8+
:no-members:
9+
:no-undoc-members:
10+
11+
The Figure class
12+
================
13+
.. autosummary::
14+
:toctree: _as_gen
15+
:template: autosummary_class_only.rst
16+
:nosignatures:
17+
18+
Figure
19+
20+
21+
Adding Axes and SubFigures
22+
==========================
23+
24+
.. autosummary::
25+
:toctree: _as_gen
26+
:template: autosummary.rst
27+
:nosignatures:
28+
29+
Figure.add_axes
30+
Figure.add_subplot
31+
Figure.subplots
32+
Figure.subplot_mosaic
33+
Figure.add_gridspec
34+
Figure.get_axes
35+
Figure.axes
36+
Figure.delaxes
37+
Figure.subfigures
38+
Figure.add_subfigure
39+
40+
Saving
41+
======
42+
43+
.. autosummary::
44+
:toctree: _as_gen
45+
:template: autosummary.rst
46+
:nosignatures:
47+
48+
Figure.savefig
49+
50+
51+
Annotating
52+
==========
53+
54+
.. autosummary::
55+
:toctree: _as_gen
56+
:template: autosummary.rst
57+
:nosignatures:
58+
59+
Figure.colorbar
60+
Figure.legend
61+
Figure.text
62+
Figure.suptitle
63+
Figure.get_suptitle
64+
Figure.supxlabel
65+
Figure.get_supxlabel
66+
Figure.supylabel
67+
Figure.get_supylabel
68+
Figure.align_labels
69+
Figure.align_xlabels
70+
Figure.align_ylabels
71+
72+
Figure geometry
73+
===============
74+
75+
.. autosummary::
76+
:toctree: _as_gen
77+
:template: autosummary.rst
78+
:nosignatures:
79+
80+
Figure.set_size_inches
81+
Figure.get_size_inches
82+
Figure.set_figheight
83+
Figure.get_figheight
84+
Figure.set_figwidth
85+
Figure.get_figwidth
86+
Figure.dpi
87+
Figure.set_dpi
88+
Figure.set_dpi
89+
90+
Subplot layout
91+
==============
92+
93+
.. autosummary::
94+
:toctree: _as_gen
95+
:template: autosummary.rst
96+
:nosignatures:
97+
98+
Figure.subplots_adjust
99+
Figure.set_layout_engine
100+
Figure.get_layout_engine
101+
102+
Discouraged or deprecated
103+
-------------------------
104+
105+
.. autosummary::
106+
:toctree: _as_gen
107+
:template: autosummary.rst
108+
:nosignatures:
109+
110+
Figure.tight_layout
111+
Figure.set_tight_layout
112+
Figure.get_tight_layout
113+
Figure.set_constrained_layout
114+
Figure.get_constrained_layout
115+
Figure.set_constrained_layout_pads
116+
Figure.get_constrained_layout_pads
117+
118+
119+
Interacting
120+
===========
121+
122+
.. seealso::
123+
124+
- :ref:`event-handling`
125+
126+
.. autosummary::
127+
:toctree: _as_gen
128+
:template: autosummary.rst
129+
:nosignatures:
130+
131+
Figure.ginput
132+
Figure.add_axobserver
133+
Figure.waitforbuttonpress
134+
Figure.pick
135+
136+
Modifying appearance
137+
====================
138+
139+
.. autosummary::
140+
:toctree: _as_gen
141+
:template: autosummary.rst
142+
:nosignatures:
143+
144+
Figure.set_frameon
145+
Figure.get_frameon
146+
Figure.set_linewidth
147+
Figure.get_linewidth
148+
Figure.set_facecolor
149+
Figure.get_facecolor
150+
Figure.set_edgecolor
151+
Figure.get_edgecolor
152+
153+
Adding and getting Artists
154+
==========================
155+
156+
.. autosummary::
157+
:toctree: _as_gen
158+
:template: autosummary.rst
159+
:nosignatures:
160+
161+
Figure.add_artist
162+
Figure.get_children
163+
Figure.figimage
164+
165+
Getting and modifying state
166+
===========================
167+
168+
.. seealso::
169+
170+
- :ref:`interactive_figures`
171+
172+
.. autosummary::
173+
:toctree: _as_gen
174+
:template: autosummary.rst
175+
:nosignatures:
176+
177+
Figure.clear
178+
Figure.gca
179+
Figure.sca
180+
Figure.get_tightbbox
181+
Figure.get_window_extent
182+
Figure.show
183+
Figure.set_canvas
184+
Figure.draw
185+
Figure.draw_without_rendering
186+
Figure.draw_artist
187+
188+
Other
189+
=====
190+
191+
.. autosummary::
192+
:toctree: _as_gen
193+
:template: autosummary.rst
194+
:nosignatures:
195+
196+
Figure.autofmt_xdate
197+
198+
SubFigure
199+
=========
200+
201+
Matplotlib has the concept of a `~.SubFigure`, which is a logical figure inside
202+
a parent `~.Figure`. It has many of the same methods as the parent. See
203+
:ref:`nested_axes_layouts`.
204+
205+
.. plot::
206+
207+
fig = plt.figure(layout='constrained', figsize=(4, 2.5), facecolor='lightgoldenrodyellow')
208+
209+
# Make two subfigures, left ones more narrow than right ones:
210+
sfigs = fig.subfigures(1, 2, width_ratios=[0.8, 1])
211+
sfigs[0].set_facecolor('khaki')
212+
sfigs[1].set_facecolor('lightsalmon')
213+
214+
# Add subplots to left subfigure:
215+
lax = sfigs[0].subplots(2, 1)
216+
sfigs[0].suptitle('Left subfigure')
217+
218+
# Add subplots to right subfigure:
219+
rax = sfigs[1].subplots(1, 2)
220+
sfigs[1].suptitle('Right subfigure')
221+
222+
# suptitle for the main figure:
223+
fig.suptitle('Figure')
224+
225+
SubFigure class
226+
---------------
227+
228+
.. autosummary::
229+
:toctree: _as_gen
230+
:template: autosummary_class_only.rst
231+
:nosignatures:
232+
233+
SubFigure
234+
235+
Adding Axes and SubFigures
236+
--------------------------
237+
.. autosummary::
238+
:toctree: _as_gen
239+
:template: autosummary.rst
240+
:nosignatures:
241+
242+
SubFigure.add_axes
243+
SubFigure.add_subplot
244+
SubFigure.subplots
245+
SubFigure.subplot_mosaic
246+
SubFigure.add_gridspec
247+
SubFigure.delaxes
248+
SubFigure.add_subfigure
249+
SubFigure.subfigures
250+
251+
Annotating
252+
----------
253+
254+
.. autosummary::
255+
:toctree: _as_gen
256+
:template: autosummary.rst
257+
:nosignatures:
258+
259+
SubFigure.colorbar
260+
SubFigure.legend
261+
SubFigure.text
262+
SubFigure.suptitle
263+
SubFigure.get_suptitle
264+
SubFigure.supxlabel
265+
SubFigure.get_supxlabel
266+
SubFigure.supylabel
267+
SubFigure.get_supylabel
268+
SubFigure.align_labels
269+
SubFigure.align_xlabels
270+
SubFigure.align_ylabels
271+
272+
Adding and getting Artists
273+
--------------------------
274+
275+
.. autosummary::
276+
:toctree: _as_gen
277+
:template: autosummary.rst
278+
:nosignatures:
279+
280+
SubFigure.add_artist
281+
SubFigure.get_children
282+
283+
Modifying appearance
284+
--------------------
285+
286+
.. autosummary::
287+
:toctree: _as_gen
288+
:template: autosummary.rst
289+
:nosignatures:
290+
291+
SubFigure.set_frameon
292+
SubFigure.get_frameon
293+
SubFigure.set_linewidth
294+
SubFigure.get_linewidth
295+
SubFigure.set_facecolor
296+
SubFigure.get_facecolor
297+
SubFigure.set_edgecolor
298+
SubFigure.get_edgecolor
299+
300+
Passthroughs
301+
------------
302+
303+
.. autosummary::
304+
:toctree: _as_gen
305+
:template: autosummary.rst
306+
:nosignatures:
307+
308+
SubFigure.set_dpi
309+
SubFigure.get_dpi
310+
311+
312+
Helper classes
313+
==============
314+
315+
FigureBase
316+
----------
317+
318+
.. autoclass:: FigureBase
319+
320+
SubplotParams
321+
-------------
322+
323+
.. autoclass:: SubplotParams

doc/api/prev_api_changes/api_changes_3.4.2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Behaviour changes
77
Rename first argument to ``subplot_mosaic``
88
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99

10-
Both `.FigureBase.subplot_mosaic`, and `.pyplot.subplot_mosaic` have had the
10+
Both `.Figure.subplot_mosaic`, and `.pyplot.subplot_mosaic` have had the
1111
first position argument renamed from *layout* to *mosaic*. This is because we
1212
are considering to consolidate *constrained_layout* and *tight_layout* keyword
1313
arguments in the Figure creation functions of `.pyplot` into a single *layout*

doc/api/prev_api_changes/api_changes_3.5.0/behaviour.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Behaviour changes
44
First argument to ``subplot_mosaic`` renamed
55
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66

7-
Both `.FigureBase.subplot_mosaic`, and `.pyplot.subplot_mosaic` have had the
7+
Both `.Figure.subplot_mosaic`, and `.pyplot.subplot_mosaic` have had the
88
first positional argument renamed from *layout* to *mosaic*. As we have
99
consolidated the *constrained_layout* and *tight_layout* keyword arguments in
1010
the Figure creation functions of `.pyplot` into a single *layout* keyword

doc/users/prev_whats_new/whats_new_3.4.0.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@ supxlabel and supylabel
634634
-----------------------
635635

636636
It is possible to add x- and y-labels to a whole figure, analogous to
637-
`.FigureBase.suptitle` using the new `.FigureBase.supxlabel` and
638-
`.FigureBase.supylabel` methods.
637+
`.Figure.suptitle` using the new `.Figure.supxlabel` and
638+
`.Figure.supylabel` methods.
639639

640640
.. plot::
641641

galleries/examples/subplots_axes_and_figures/figure_title.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
66
Each axes can have a title (or actually three - one each with *loc* "left",
77
"center", and "right"), but is sometimes desirable to give a whole figure
8-
(or `.SubFigure`) an overall title, using `.FigureBase.suptitle`.
8+
(or `.SubFigure`) an overall title, using `.Figure.suptitle`.
99
10-
We can also add figure-level x- and y-labels using `.FigureBase.supxlabel` and
11-
`.FigureBase.supylabel`.
10+
We can also add figure-level x- and y-labels using `.Figure.supxlabel` and
11+
`.Figure.supylabel`.
1212
"""
1313

1414
import matplotlib.pyplot as plt
@@ -31,8 +31,8 @@
3131
fig.suptitle('Different types of oscillations', fontsize=16)
3232

3333
# %%
34-
# A global x- or y-label can be set using the `.FigureBase.supxlabel` and
35-
# `.FigureBase.supylabel` methods.
34+
# A global x- or y-label can be set using the `.Figure.supxlabel` and
35+
# `.Figure.supylabel` methods.
3636

3737

3838
with get_sample_data('Stocks.csv') as file:

galleries/examples/subplots_axes_and_figures/gridspec_nested.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
set the position for a nested grid of subplots.
88
99
Note that the same functionality can be achieved more directly with
10-
`~.FigureBase.subfigures`; see
10+
`~.Figure.subfigures`; see
1111
:doc:`/gallery/subplots_axes_and_figures/subfigures`.
1212
1313
"""

galleries/users_explain/axes/arranging_axes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ def annotate_axes(ax, text, fontsize=18):
228228
fig.suptitle('plt.subplot_mosaic()')
229229

230230
# %%
231+
# .. _nested_axes_layouts:
232+
#
231233
# Nested Axes layouts
232234
# -------------------
233235
#

0 commit comments

Comments
 (0)