1
1
"""
2
- The figure module provides the top-level
3
- :class:`~matplotlib.artist.Artist`, the :class:`Figure`, which
4
- contains all the plot elements. The following classes are defined
2
+ `matplotlib.figure` implements the following classes:
5
3
6
- :class:`SubplotParams `
7
- control the default spacing of the subplots
4
+ `Figure `
5
+ Top level `~matplotlib.artist.Artist`, which holds all plot elements.
8
6
9
- :class:`Figure `
10
- Top level container for all plot elements .
7
+ `SubplotParams `
8
+ Control the default spacing between subplots .
11
9
"""
12
10
13
11
import logging
@@ -47,20 +45,18 @@ def _stale_figure_callback(self, val):
47
45
48
46
class _AxesStack (cbook .Stack ):
49
47
"""
50
- Specialization of the `.Stack` to handle all tracking of
51
- `~matplotlib.axes.Axes` in a `.Figure`.
52
- This stack stores ``key, (ind, axes)`` pairs, where:
48
+ Specialization of `.Stack`, to handle all tracking of `~.axes.Axes` in a
49
+ `.Figure`.
53
50
54
- * **key** should be a hash of the args and kwargs
55
- used in generating the Axes.
56
- * **ind** is a serial number for tracking the order
57
- in which axes were added.
51
+ This stack stores ``key, (ind, axes)`` pairs, where:
58
52
59
- The AxesStack is a callable, where ``ax_stack()`` returns
60
- the current axes. Alternatively the :meth:`current_key_axes` will
61
- return the current key and associated axes.
53
+ * **key** is a hash of the args and kwargs used in generating the Axes.
54
+ * **ind** is a serial index tracking the order in which axes were added.
62
55
56
+ AxesStack is a callable; calling it returns the current axes.
57
+ The `current_key_axes` method returns the current key and associated axes.
63
58
"""
59
+
64
60
def __init__ (self ):
65
61
super ().__init__ ()
66
62
self ._ind = 0
@@ -284,7 +280,7 @@ def __init__(self,
284
280
frameon : bool, default: :rc:`figure.frameon`
285
281
If ``False``, suppress drawing the figure background patch.
286
282
287
- subplotpars : :class: `SubplotParams`
283
+ subplotpars : `SubplotParams`
288
284
Subplot parameters. If not given, the default subplot
289
285
parameters :rc:`figure.subplot.*` are used.
290
286
@@ -384,10 +380,9 @@ def show(self, warn=True):
384
380
"""
385
381
If using a GUI backend with pyplot, display the figure window.
386
382
387
- If the figure was not created using
388
- :func:`~matplotlib.pyplot.figure`, it will lack a
389
- :class:`~matplotlib.backend_bases.FigureManagerBase`, and
390
- will raise an AttributeError.
383
+ If the figure was not created using `~.pyplot.figure`, it will lack
384
+ a `~.backend_bases.FigureManagerBase`, and this method will raise an
385
+ AttributeError.
391
386
392
387
.. warning::
393
388
This does not manage an GUI event loop. Consequently, the figure
@@ -403,7 +398,7 @@ def show(self, warn=True):
403
398
404
399
Parameters
405
400
----------
406
- warn : bool
401
+ warn : bool, default: True
407
402
If ``True`` and we are not running headless (i.e. on Linux with an
408
403
unset DISPLAY), issue warning when called on a non-GUI backend.
409
404
"""
@@ -699,7 +694,7 @@ def suptitle(self, t, **kwargs):
699
694
:rc:`figure.titleweight` are ignored in this case.
700
695
701
696
**kwargs
702
- Additional kwargs are :class: `matplotlib.text.Text` properties.
697
+ Additional kwargs are `matplotlib.text.Text` properties.
703
698
704
699
Examples
705
700
--------
@@ -782,7 +777,7 @@ def figimage(self, X, xo=0, yo=0, alpha=None, norm=None, cmap=None,
782
777
The alpha blending value.
783
778
784
779
norm : `matplotlib.colors.Normalize`
785
- A :class: `.Normalize` instance to map the luminance to the
780
+ A `.Normalize` instance to map the luminance to the
786
781
interval [0, 1].
787
782
788
783
cmap : str or `matplotlib.colors.Colormap`, default: :rc:`image.cmap`
@@ -801,7 +796,7 @@ def figimage(self, X, xo=0, yo=0, alpha=None, norm=None, cmap=None,
801
796
802
797
Returns
803
798
-------
804
- :class: `matplotlib.image.FigureImage`
799
+ `matplotlib.image.FigureImage`
805
800
806
801
Other Parameters
807
802
----------------
@@ -1019,11 +1014,11 @@ def set_frameon(self, b):
1019
1014
1020
1015
def add_artist (self , artist , clip = False ):
1021
1016
"""
1022
- Add any :class:`~matplotlib.artist .Artist` to the figure.
1017
+ Add an ` .Artist` to the figure.
1023
1018
1024
- Usually artists are added to axes objects using
1025
- :meth:`matplotlib.axes.Axes.add_artist`, but use this method in the
1026
- rare cases that adding directly to the figure is necessary .
1019
+ Usually artists are added to axes objects using `.Axes.add_artist`;
1020
+ this method can be used in the rare cases where one needs to add
1021
+ artists directly to the figure instead .
1027
1022
1028
1023
Parameters
1029
1024
----------
@@ -1451,9 +1446,8 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
1451
1446
up being 1x1.
1452
1447
1453
1448
subplot_kw : dict, optional
1454
- Dict with keywords passed to the
1455
- :meth:`~matplotlib.figure.Figure.add_subplot` call used to create
1456
- each subplot.
1449
+ Dict with keywords passed to the `.Figure.add_subplot` call used to
1450
+ create each subplot.
1457
1451
1458
1452
gridspec_kw : dict, optional
1459
1453
Dict with keywords passed to the
@@ -1667,9 +1661,7 @@ def clf(self, keep_observers=False):
1667
1661
self .stale = True
1668
1662
1669
1663
def clear (self , keep_observers = False ):
1670
- """
1671
- Clear the figure -- synonym for :meth:`clf`.
1672
- """
1664
+ """Clear the figure -- synonym for `clf`."""
1673
1665
self .clf (keep_observers = keep_observers )
1674
1666
1675
1667
@allow_rasterization
@@ -1727,8 +1719,9 @@ def draw(self, renderer):
1727
1719
1728
1720
def draw_artist (self , a ):
1729
1721
"""
1730
- Draw :class:`matplotlib.artist.Artist` instance *a* only.
1731
- This is available only after the figure is drawn.
1722
+ Draw `.Artist` instance *a* only.
1723
+
1724
+ This can only be called after the figure has been drawn.
1732
1725
"""
1733
1726
if self ._cachedRenderer is None :
1734
1727
raise AttributeError ("draw_artist can only be used after an "
@@ -2206,9 +2199,8 @@ def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw):
2206
2199
def subplots_adjust (self , left = None , bottom = None , right = None , top = None ,
2207
2200
wspace = None , hspace = None ):
2208
2201
"""
2209
- Update the :class:`SubplotParams` with *kwargs* (defaulting to rc when
2210
- *None*) and update the subplot locations.
2211
-
2202
+ Update the `SubplotParams` with *kwargs* (defaulting to rc when
2203
+ *None*), and update the subplot locations.
2212
2204
"""
2213
2205
if self .get_constrained_layout ():
2214
2206
self .set_constrained_layout (False )
0 commit comments