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

Skip to content

Commit 448e9f6

Browse files
committed
DOC: organize figure API [ci doc]
1 parent 4c73219 commit 448e9f6

File tree

11 files changed

+344
-31
lines changed

11 files changed

+344
-31
lines changed

doc/api/figure_api.rst

Lines changed: 301 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,304 @@
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+
Figure.autofmt_xdate
72+
73+
74+
Figure geometry
75+
===============
76+
77+
.. autosummary::
78+
:toctree: _as_gen
79+
:template: autosummary.rst
80+
:nosignatures:
81+
82+
Figure.set_size_inches
83+
Figure.get_size_inches
84+
Figure.set_figheight
85+
Figure.get_figheight
86+
Figure.set_figwidth
87+
Figure.get_figwidth
88+
Figure.dpi
89+
Figure.set_dpi
90+
Figure.set_dpi
91+
92+
Subplot layout
93+
==============
94+
95+
.. autosummary::
96+
:toctree: _as_gen
97+
:template: autosummary.rst
98+
:nosignatures:
99+
100+
Figure.subplots_adjust
101+
Figure.set_layout_engine
102+
Figure.get_layout_engine
103+
104+
Discouraged or deprecated
105+
-------------------------
106+
107+
.. autosummary::
108+
:toctree: _as_gen
109+
:template: autosummary.rst
110+
:nosignatures:
111+
112+
Figure.tight_layout
113+
Figure.set_tight_layout
114+
Figure.get_tight_layout
115+
Figure.set_constrained_layout
116+
Figure.get_constrained_layout
117+
Figure.set_constrained_layout_pads
118+
Figure.get_constrained_layout_pads
119+
120+
Interactive
121+
===========
122+
123+
.. seealso::
124+
125+
- :ref:`event-handling`
126+
127+
.. autosummary::
128+
:toctree: _as_gen
129+
:template: autosummary.rst
130+
:nosignatures:
131+
132+
Figure.ginput
133+
Figure.add_axobserver
134+
Figure.waitforbuttonpress
135+
Figure.pick
136+
137+
Modifying appearance
138+
====================
139+
140+
.. autosummary::
141+
:toctree: _as_gen
142+
:template: autosummary.rst
143+
:nosignatures:
144+
145+
Figure.set_frameon
146+
Figure.get_frameon
147+
Figure.set_linewidth
148+
Figure.get_linewidth
149+
Figure.set_facecolor
150+
Figure.get_facecolor
151+
Figure.set_edgecolor
152+
Figure.get_edgecolor
153+
154+
Adding and getting Artists
155+
==========================
156+
157+
.. autosummary::
158+
:toctree: _as_gen
159+
:template: autosummary.rst
160+
:nosignatures:
161+
162+
Figure.add_artist
163+
Figure.get_children
164+
Figure.figimage
165+
166+
Getting and modifying state
167+
===========================
168+
169+
.. seealso::
170+
171+
- :ref:`interactive_figures`
172+
173+
.. autosummary::
174+
:toctree: _as_gen
175+
:template: autosummary.rst
176+
:nosignatures:
177+
178+
Figure.clear
179+
Figure.gca
180+
Figure.sca
181+
Figure.get_tightbbox
182+
Figure.get_window_extent
183+
Figure.show
184+
Figure.set_canvas
185+
Figure.draw
186+
Figure.draw_without_rendering
187+
Figure.draw_artist
188+
189+
.. _figure-api-subfigure:
190+
191+
SubFigure
192+
=========
193+
194+
Matplotlib has the concept of a `~.SubFigure`, which is a logical figure inside
195+
a parent `~.Figure`. It has many of the same methods as the parent. See
196+
:ref:`nested_axes_layouts`.
197+
198+
.. plot::
199+
200+
fig = plt.figure(layout='constrained', figsize=(4, 2.5), facecolor='lightgoldenrodyellow')
201+
202+
# Make two subfigures, left ones more narrow than right ones:
203+
sfigs = fig.subfigures(1, 2, width_ratios=[0.8, 1])
204+
sfigs[0].set_facecolor('khaki')
205+
sfigs[1].set_facecolor('lightsalmon')
206+
207+
# Add subplots to left subfigure:
208+
lax = sfigs[0].subplots(2, 1)
209+
sfigs[0].suptitle('Left subfigure')
210+
211+
# Add subplots to right subfigure:
212+
rax = sfigs[1].subplots(1, 2)
213+
sfigs[1].suptitle('Right subfigure')
214+
215+
# suptitle for the main figure:
216+
fig.suptitle('Figure')
217+
218+
SubFigure class
219+
---------------
220+
221+
.. autosummary::
222+
:toctree: _as_gen
223+
:template: autosummary_class_only.rst
224+
:nosignatures:
225+
226+
SubFigure
227+
228+
Adding Axes and SubFigures
229+
--------------------------
230+
.. autosummary::
231+
:toctree: _as_gen
232+
:template: autosummary.rst
233+
:nosignatures:
234+
235+
SubFigure.add_axes
236+
SubFigure.add_subplot
237+
SubFigure.subplots
238+
SubFigure.subplot_mosaic
239+
SubFigure.add_gridspec
240+
SubFigure.delaxes
241+
SubFigure.add_subfigure
242+
SubFigure.subfigures
243+
244+
Annotating
245+
----------
246+
247+
.. autosummary::
248+
:toctree: _as_gen
249+
:template: autosummary.rst
250+
:nosignatures:
251+
252+
SubFigure.colorbar
253+
SubFigure.legend
254+
SubFigure.text
255+
SubFigure.suptitle
256+
SubFigure.get_suptitle
257+
SubFigure.supxlabel
258+
SubFigure.get_supxlabel
259+
SubFigure.supylabel
260+
SubFigure.get_supylabel
261+
SubFigure.align_labels
262+
SubFigure.align_xlabels
263+
SubFigure.align_ylabels
264+
265+
Adding and getting Artists
266+
--------------------------
267+
268+
.. autosummary::
269+
:toctree: _as_gen
270+
:template: autosummary.rst
271+
:nosignatures:
272+
273+
SubFigure.add_artist
274+
SubFigure.get_children
275+
276+
Modifying appearance
277+
--------------------
278+
279+
.. autosummary::
280+
:toctree: _as_gen
281+
:template: autosummary.rst
282+
:nosignatures:
283+
284+
SubFigure.set_frameon
285+
SubFigure.get_frameon
286+
SubFigure.set_linewidth
287+
SubFigure.get_linewidth
288+
SubFigure.set_facecolor
289+
SubFigure.get_facecolor
290+
SubFigure.set_edgecolor
291+
SubFigure.get_edgecolor
292+
293+
Passthroughs
294+
------------
295+
296+
.. autosummary::
297+
:toctree: _as_gen
298+
:template: autosummary.rst
299+
:nosignatures:
300+
301+
SubFigure.set_dpi
302+
SubFigure.get_dpi
303+
304+
305+
FigureBase parent class
306+
=======================
307+
308+
.. autoclass:: FigureBase

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)