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

Skip to content

Commit 37074c5

Browse files
authored
Merge pull request #15805 from timhoffm/doc-figwidth
Improve docs on figure size
2 parents 96152ad + 8ea46e4 commit 37074c5

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
@@ -861,7 +861,13 @@ def set_size_inches(self, w, h=None, forward=True):
861861
862862
See Also
863863
--------
864-
matplotlib.Figure.get_size_inches
864+
matplotlib.figure.Figure.get_size_inches
865+
matplotlib.figure.Figure.set_figwidth
866+
matplotlib.figure.Figure.set_figheight
867+
868+
Notes
869+
-----
870+
To transform from pixels to inches divide by `Figure.dpi`.
865871
"""
866872
if h is None: # Got called with a single pair as argument.
867873
w, h = w
@@ -889,7 +895,13 @@ def get_size_inches(self):
889895
890896
See Also
891897
--------
892-
matplotlib.Figure.set_size_inches
898+
matplotlib.figure.Figure.set_size_inches
899+
matplotlib.figure.Figure.get_figwidth
900+
matplotlib.figure.Figure.get_figheight
901+
902+
Notes
903+
-----
904+
The size in pixels can be obtained by multiplying with `Figure.dpi`.
893905
"""
894906
return np.array(self.bbox_inches.p1)
895907

@@ -902,11 +914,11 @@ def get_facecolor(self):
902914
return self.patch.get_facecolor()
903915

904916
def get_figwidth(self):
905-
"""Return the figure width as a float."""
917+
"""Return the figure width in inches."""
906918
return self.bbox_inches.width
907919

908920
def get_figheight(self):
909-
"""Return the figure height as a float."""
921+
"""Return the figure height in inches."""
910922
return self.bbox_inches.height
911923

912924
def get_dpi(self):
@@ -960,6 +972,12 @@ def set_figwidth(self, val, forward=True):
960972
----------
961973
val : float
962974
forward : bool
975+
See `set_size_inches`.
976+
977+
See Also
978+
--------
979+
matplotlib.figure.Figure.set_figheight
980+
matplotlib.figure.Figure.set_size_inches
963981
"""
964982
self.set_size_inches(val, self.get_figheight(), forward=forward)
965983

@@ -971,6 +989,12 @@ def set_figheight(self, val, forward=True):
971989
----------
972990
val : float
973991
forward : bool
992+
See `set_size_inches`.
993+
994+
See Also
995+
--------
996+
matplotlib.figure.Figure.set_figwidth
997+
matplotlib.figure.Figure.set_size_inches
974998
"""
975999
self.set_size_inches(self.get_figwidth(), val, forward=forward)
9761000

0 commit comments

Comments
 (0)