From 640d05f6b4080a6c26b43bdf279470755a7cdef3 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 24 Feb 2014 21:04:43 -0500 Subject: [PATCH 1/3] DOC/ENH : get/set_size_inches Added links between `get_size_inches` and `set_size_inches` Added an `np.array` call to `get_size_inches` to return a copy of the size, instead of a reference to the internal np.array. Closes #2303 --- lib/matplotlib/figure.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 324fecaeb906..c6cb628428cd 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -635,6 +635,8 @@ def set_size_inches(self, *args, **kwargs): from the shell ACCEPTS: a w,h tuple with w,h in inches + + .. seealso:: :func:`~matplotlib.Figure.get_size_inches` """ forward = kwargs.get('forward', False) @@ -655,7 +657,17 @@ def set_size_inches(self, *args, **kwargs): manager.resize(int(canvasw), int(canvash)) def get_size_inches(self): - return self.bbox_inches.p1 + """ + Returns the current size of the figure in inches as an numpy array. + + Returns + ------- + size : ndarray + The size of the figure in inches + + .. seealso:: :func:`~matplotlib.Figure.set_size_inches` + """ + return np.array(self.bbox_inches.p1) def get_edgecolor(self): 'Get the edge color of the Figure rectangle' From d79dbc73501cd2ae53649f008e4daff26ce8634b Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 25 Feb 2014 23:47:38 -0500 Subject: [PATCH 2/3] DOC : minor tweaks to set/get_size_inches - better numpydoc style - added inch <-> cm conversion factor --- lib/matplotlib/figure.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index c6cb628428cd..0c70c0026862 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -623,7 +623,7 @@ def set_size_inches(self, *args, **kwargs): """ set_size_inches(w,h, forward=False) - Set the figure size in inches + Set the figure size in inches (1in == 2.54cm) Usage:: @@ -636,7 +636,10 @@ def set_size_inches(self, *args, **kwargs): ACCEPTS: a w,h tuple with w,h in inches - .. seealso:: :func:`~matplotlib.Figure.get_size_inches` + See Also + -------- + + :func:`~matplotlib.Figure.get_size_inches` """ forward = kwargs.get('forward', False) @@ -658,14 +661,18 @@ def set_size_inches(self, *args, **kwargs): def get_size_inches(self): """ - Returns the current size of the figure in inches as an numpy array. + Returns the current size of the figure in inches (1in == 2.54cm) + as an numpy array. Returns ------- size : ndarray The size of the figure in inches - .. seealso:: :func:`~matplotlib.Figure.set_size_inches` + Also See + -------- + + :func:`~matplotlib.Figure.set_size_inches` """ return np.array(self.bbox_inches.p1) From 08b68c2fae153385e26399dad2596c2a8255918a Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 8 Apr 2014 08:47:48 -0400 Subject: [PATCH 3/3] DOC : transposed incorrect section title --- lib/matplotlib/figure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 0c70c0026862..a9279a854208 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -669,7 +669,7 @@ def get_size_inches(self): size : ndarray The size of the figure in inches - Also See + See Also -------- :func:`~matplotlib.Figure.set_size_inches`