@@ -62,8 +62,8 @@ def _stale_figure_callback(self, val):
62
62
63
63
class AxesStack (Stack ):
64
64
"""
65
- Specialization of the `. Stack` to handle all tracking of `. Axes` in a
66
- `.Figure`. This stack stores ``key, (ind, axes)`` pairs, where:
65
+ Specialization of the Stack to handle all tracking of Axes in a Figure.
66
+ This stack stores ``key, (ind, axes)`` pairs, where:
67
67
68
68
* **key** should be a hash of the args and kwargs
69
69
used in generating the Axes.
@@ -81,7 +81,7 @@ def __init__(self):
81
81
82
82
def as_list (self ):
83
83
"""
84
- Return a list of the Axes instances that have been added to the figure.
84
+ Return a list of the Axes instances that have been added to the figure
85
85
"""
86
86
ia_list = [a for k , a in self ._elements ]
87
87
ia_list .sort ()
@@ -90,7 +90,7 @@ def as_list(self):
90
90
def get (self , key ):
91
91
"""
92
92
Return the Axes instance that was added with *key*.
93
- If it is not present, return * None* .
93
+ If it is not present, return None.
94
94
"""
95
95
item = dict (self ._elements ).get (key )
96
96
if item is None :
@@ -692,55 +692,31 @@ def suptitle(self, t, **kwargs):
692
692
"""
693
693
Add a centered title to the figure.
694
694
695
- Parameters
696
- ----------
697
- t : str
698
- The title text.
699
-
700
- x : float, default 0.5
701
- The x location of the text in figure coordinates.
702
-
703
- y : float, default 0.98
704
- The y location of the text in figure coordinates.
705
-
706
- horizontalalignment, ha : {'center', 'left', right'}, default: 'center'
707
- The horizontal alignment of the text.
695
+ kwargs are :class:`matplotlib.text.Text` properties. Using figure
696
+ coordinates, the defaults are:
708
697
709
- verticalalignment, va : {'top', 'center', 'bottom', 'baseline'}, \
710
- default: 'top'
711
- The vertical alignment of the text.
698
+ x : 0.5
699
+ The x location of the text in figure coords
712
700
713
- fontsize, size : default: :rc:`figure.titlesize`
714
- The font size of the text. See `.Text.set_size` for possible
715
- values.
716
-
717
- fontweight, weight : default: :rc:`figuretitleweight`
718
- The font weight of the text. See `.Text.set_weight` for possible
719
- values.
720
-
721
-
722
- Returns
723
- -------
724
- text
725
- The `.Text` instance of the title.
701
+ y : 0.98
702
+ The y location of the text in figure coords
726
703
704
+ horizontalalignment : 'center'
705
+ The horizontal alignment of the text
727
706
728
- Other Parameters
729
- ----------------
730
- fontproperties : None or dict, optional
731
- A dict of font properties. If *fontproperties* is given the
732
- default values for font size and weight are taken from the
733
- `FontProperties` defaults. :rc:`figure.titlesize` and
734
- :rc:`figure.titleweight` are ignored in this case.
707
+ verticalalignment : 'top'
708
+ The vertical alignment of the text
735
709
736
- **kwargs
737
- Additional kwargs are :class:`matplotlib.text.Text` properties.
710
+ If the `fontproperties` keyword argument is given then the
711
+ rcParams defaults for `fontsize` (`figure.titlesize`) and
712
+ `fontweight` (`figure.titleweight`) will be ignored in favour
713
+ of the `FontProperties` defaults.
738
714
715
+ A :class:`matplotlib.text.Text` instance is returned.
739
716
740
- Examples
741
- --------
717
+ Example::
742
718
743
- >>> fig.suptitle('This is the figure title', fontsize=12)
719
+ fig.suptitle('this is the figure title', fontsize=12)
744
720
"""
745
721
x = kwargs .pop ('x' , 0.5 )
746
722
y = kwargs .pop ('y' , 0.98 )
@@ -895,9 +871,9 @@ def figimage(self, X,
895
871
return im
896
872
897
873
def set_size_inches (self , w , h = None , forward = True ):
898
- """Set the figure size in inches.
874
+ """Set the figure size in inches (1in == 2.54cm)
899
875
900
- Call signatures ::
876
+ Usage ::
901
877
902
878
fig.set_size_inches(w, h) # OR
903
879
fig.set_size_inches((w, h))
@@ -906,7 +882,7 @@ def set_size_inches(self, w, h=None, forward=True):
906
882
automatically updated; e.g., you can resize the figure window
907
883
from the shell
908
884
909
- ACCEPTS: a ( w, h) tuple with w, h in inches
885
+ ACCEPTS: a w, h tuple with w, h in inches
910
886
911
887
See Also
912
888
--------
@@ -992,9 +968,9 @@ def set_facecolor(self, color):
992
968
993
969
def set_dpi (self , val ):
994
970
"""
995
- Set the resolution of the figure in dots-per-inch.
971
+ Set the dots-per-inch of the figure
996
972
997
- .. ACCEPTS: float
973
+ ACCEPTS: float
998
974
"""
999
975
self .dpi = val
1000
976
self .stale = True
@@ -1003,21 +979,21 @@ def set_figwidth(self, val, forward=True):
1003
979
"""
1004
980
Set the width of the figure in inches
1005
981
1006
- .. ACCEPTS: float
982
+ ACCEPTS: float
1007
983
"""
1008
984
self .set_size_inches (val , self .get_figheight (), forward = forward )
1009
985
1010
986
def set_figheight (self , val , forward = True ):
1011
987
"""
1012
988
Set the height of the figure in inches
1013
989
1014
- .. ACCEPTS: float
990
+ ACCEPTS: float
1015
991
"""
1016
992
self .set_size_inches (self .get_figwidth (), val , forward = forward )
1017
993
1018
994
def set_frameon (self , b ):
1019
995
"""
1020
- Set whether the figure frame (background) is displayed or invisible.
996
+ Set whether the figure frame (background) is displayed or invisible
1021
997
1022
998
ACCEPTS: boolean
1023
999
"""
@@ -2103,7 +2079,7 @@ def subplots_adjust(self, *args, **kwargs):
2103
2079
Call signature::
2104
2080
2105
2081
subplots_adjust(left=None, bottom=None, right=None, top=None,
2106
- wspace=None, hspace=None)
2082
+ wspace=None, hspace=None)
2107
2083
2108
2084
Update the :class:`SubplotParams` with *kwargs* (defaulting to rc when
2109
2085
*None*) and update the subplot locations.
@@ -2204,8 +2180,8 @@ def get_tightbbox(self, renderer):
2204
2180
"""
2205
2181
Return a (tight) bounding box of the figure in inches.
2206
2182
2207
- Currently, this takes only axes title, axis labels, and axis
2208
- ticklabels into account . Needs improvement.
2183
+ It only accounts axes title, axis labels, and axis
2184
+ ticklabels. Needs improvement.
2209
2185
"""
2210
2186
2211
2187
bb = []
@@ -2461,50 +2437,30 @@ def align_labels(self, axs=None):
2461
2437
2462
2438
def figaspect (arg ):
2463
2439
"""
2464
- Calculate the width and height for a figure with a specified aspect ratio.
2465
-
2466
- While the height is taken from :rc:`figure.figsize`, the width is
2467
- adjusted to match the desired aspect ratio. Additionally, it is ensured
2468
- that the width is in the range [4., 16.] and the height is in the range
2469
- [2., 16.]. If necessary, the default height is adjusted to ensure this.
2470
-
2471
- Parameters
2472
- ----------
2473
- arg : scalar or 2d array
2474
- If a scalar, this defines the aspect ratio (i.e. the ratio height /
2475
- width).
2476
- In case of an array the aspect ratio is number of rows / number of
2477
- columns, so that the array could be fitted in the figure undistorted.
2478
-
2479
- Returns
2480
- -------
2481
- width, height
2482
- The figure size in inches.
2483
-
2484
- Notes
2485
- -----
2486
- If you want to create an axes within the figure, that still presevers the
2487
- aspect ratio, be sure to create it with equal width and height. See
2488
- examples below.
2489
-
2490
- Thanks to Fernando Perez for this function.
2491
-
2492
- Examples
2493
- --------
2494
- Make a figure twice as tall as it is wide::
2495
-
2496
- w, h = figaspect(2.)
2497
- fig = Figure(figsize=(w, h))
2498
- ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
2499
- ax.imshow(A, **kwargs)
2500
-
2501
- Make a figure with the proper aspect for an array::
2502
-
2503
- A = rand(5,3)
2504
- w, h = figaspect(A)
2505
- fig = Figure(figsize=(w, h))
2506
- ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
2507
- ax.imshow(A, **kwargs)
2440
+ Create a figure with specified aspect ratio. If *arg* is a number,
2441
+ use that aspect ratio. If *arg* is an array, figaspect will
2442
+ determine the width and height for a figure that would fit array
2443
+ preserving aspect ratio. The figure width, height in inches are
2444
+ returned. Be sure to create an axes with equal with and height,
2445
+ e.g.,
2446
+
2447
+ Example usage::
2448
+
2449
+ # make a figure twice as tall as it is wide
2450
+ w, h = figaspect(2.)
2451
+ fig = Figure(figsize=(w,h))
2452
+ ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
2453
+ ax.imshow(A, **kwargs)
2454
+
2455
+
2456
+ # make a figure with the proper aspect for an array
2457
+ A = rand(5,3)
2458
+ w, h = figaspect(A)
2459
+ fig = Figure(figsize=(w,h))
2460
+ ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
2461
+ ax.imshow(A, **kwargs)
2462
+
2463
+ Thanks to Fernando Perez for this function
2508
2464
"""
2509
2465
2510
2466
isarray = hasattr (arg , 'shape' ) and not np .isscalar (arg )
0 commit comments