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

Skip to content

Commit 8ea46e4

Browse files
committed
Improve docs on figure size
1 parent 04acc1b commit 8ea46e4

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

lib/matplotlib/figure.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,13 @@ def set_size_inches(self, w, h=None, forward=True):
862862
863863
See Also
864864
--------
865-
matplotlib.Figure.get_size_inches
865+
matplotlib.figure.Figure.get_size_inches
866+
matplotlib.figure.Figure.set_figwidth
867+
matplotlib.figure.Figure.set_figheight
868+
869+
Notes
870+
-----
871+
To transform from pixels to inches divide by `Figure.dpi`.
866872
"""
867873
if h is None: # Got called with a single pair as argument.
868874
w, h = w
@@ -890,7 +896,13 @@ def get_size_inches(self):
890896
891897
See Also
892898
--------
893-
matplotlib.Figure.set_size_inches
899+
matplotlib.figure.Figure.set_size_inches
900+
matplotlib.figure.Figure.get_figwidth
901+
matplotlib.figure.Figure.get_figheight
902+
903+
Notes
904+
-----
905+
The size in pixels can be obtained by multiplying with `Figure.dpi`.
894906
"""
895907
return np.array(self.bbox_inches.p1)
896908

@@ -903,11 +915,11 @@ def get_facecolor(self):
903915
return self.patch.get_facecolor()
904916

905917
def get_figwidth(self):
906-
"""Return the figure width as a float."""
918+
"""Return the figure width in inches."""
907919
return self.bbox_inches.width
908920

909921
def get_figheight(self):
910-
"""Return the figure height as a float."""
922+
"""Return the figure height in inches."""
911923
return self.bbox_inches.height
912924

913925
def get_dpi(self):
@@ -961,6 +973,12 @@ def set_figwidth(self, val, forward=True):
961973
----------
962974
val : float
963975
forward : bool
976+
See `set_size_inches`.
977+
978+
See Also
979+
--------
980+
matplotlib.figure.Figure.set_figheight
981+
matplotlib.figure.Figure.set_size_inches
964982
"""
965983
self.set_size_inches(val, self.get_figheight(), forward=forward)
966984

@@ -972,6 +990,12 @@ def set_figheight(self, val, forward=True):
972990
----------
973991
val : float
974992
forward : bool
993+
See `set_size_inches`.
994+
995+
See Also
996+
--------
997+
matplotlib.figure.Figure.set_figwidth
998+
matplotlib.figure.Figure.set_size_inches
975999
"""
9761000
self.set_size_inches(self.get_figwidth(), val, forward=forward)
9771001

0 commit comments

Comments
 (0)