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

Skip to content

Commit a8ac10d

Browse files
committed
Revert "Merge pull request #10666 from timhoffm/doc-figure-part-2"
This reverts commit 68beb9a. Changes to lib should not be backported to the -doc branch
1 parent 68beb9a commit a8ac10d

File tree

1 file changed

+56
-100
lines changed

1 file changed

+56
-100
lines changed

lib/matplotlib/figure.py

Lines changed: 56 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def _stale_figure_callback(self, val):
6262

6363
class AxesStack(Stack):
6464
"""
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:
6767
6868
* **key** should be a hash of the args and kwargs
6969
used in generating the Axes.
@@ -81,7 +81,7 @@ def __init__(self):
8181

8282
def as_list(self):
8383
"""
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
8585
"""
8686
ia_list = [a for k, a in self._elements]
8787
ia_list.sort()
@@ -90,7 +90,7 @@ def as_list(self):
9090
def get(self, key):
9191
"""
9292
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.
9494
"""
9595
item = dict(self._elements).get(key)
9696
if item is None:
@@ -692,55 +692,31 @@ def suptitle(self, t, **kwargs):
692692
"""
693693
Add a centered title to the figure.
694694
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:
708697
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
712700
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
726703
704+
horizontalalignment : 'center'
705+
The horizontal alignment of the text
727706
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
735709
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.
738714
715+
A :class:`matplotlib.text.Text` instance is returned.
739716
740-
Examples
741-
--------
717+
Example::
742718
743-
>>> fig.suptitle('This is the figure title', fontsize=12)
719+
fig.suptitle('this is the figure title', fontsize=12)
744720
"""
745721
x = kwargs.pop('x', 0.5)
746722
y = kwargs.pop('y', 0.98)
@@ -895,9 +871,9 @@ def figimage(self, X,
895871
return im
896872

897873
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)
899875
900-
Call signatures::
876+
Usage ::
901877
902878
fig.set_size_inches(w, h) # OR
903879
fig.set_size_inches((w, h))
@@ -906,7 +882,7 @@ def set_size_inches(self, w, h=None, forward=True):
906882
automatically updated; e.g., you can resize the figure window
907883
from the shell
908884
909-
ACCEPTS: a (w, h) tuple with w, h in inches
885+
ACCEPTS: a w, h tuple with w, h in inches
910886
911887
See Also
912888
--------
@@ -992,9 +968,9 @@ def set_facecolor(self, color):
992968

993969
def set_dpi(self, val):
994970
"""
995-
Set the resolution of the figure in dots-per-inch.
971+
Set the dots-per-inch of the figure
996972
997-
.. ACCEPTS: float
973+
ACCEPTS: float
998974
"""
999975
self.dpi = val
1000976
self.stale = True
@@ -1003,21 +979,21 @@ def set_figwidth(self, val, forward=True):
1003979
"""
1004980
Set the width of the figure in inches
1005981
1006-
.. ACCEPTS: float
982+
ACCEPTS: float
1007983
"""
1008984
self.set_size_inches(val, self.get_figheight(), forward=forward)
1009985

1010986
def set_figheight(self, val, forward=True):
1011987
"""
1012988
Set the height of the figure in inches
1013989
1014-
.. ACCEPTS: float
990+
ACCEPTS: float
1015991
"""
1016992
self.set_size_inches(self.get_figwidth(), val, forward=forward)
1017993

1018994
def set_frameon(self, b):
1019995
"""
1020-
Set whether the figure frame (background) is displayed or invisible.
996+
Set whether the figure frame (background) is displayed or invisible
1021997
1022998
ACCEPTS: boolean
1023999
"""
@@ -2103,7 +2079,7 @@ def subplots_adjust(self, *args, **kwargs):
21032079
Call signature::
21042080
21052081
subplots_adjust(left=None, bottom=None, right=None, top=None,
2106-
wspace=None, hspace=None)
2082+
wspace=None, hspace=None)
21072083
21082084
Update the :class:`SubplotParams` with *kwargs* (defaulting to rc when
21092085
*None*) and update the subplot locations.
@@ -2204,8 +2180,8 @@ def get_tightbbox(self, renderer):
22042180
"""
22052181
Return a (tight) bounding box of the figure in inches.
22062182
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.
22092185
"""
22102186

22112187
bb = []
@@ -2461,50 +2437,30 @@ def align_labels(self, axs=None):
24612437

24622438
def figaspect(arg):
24632439
"""
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
25082464
"""
25092465

25102466
isarray = hasattr(arg, 'shape') and not np.isscalar(arg)

0 commit comments

Comments
 (0)