Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ def set_size_inches(self, w, h=None, forward=False):
manager.resize(int(canvasw), int(canvash))
self.stale = True

def set_size_cm(self, w, h=None, **kwargs):
return self.set_size_inches(w*(1/2.54), h*(1/2.54) if h is not None else None, **kwargs)

def get_size_inches(self):
"""
Returns the current size of the figure in inches (1in == 2.54cm)
Expand All @@ -725,6 +728,9 @@ def get_size_inches(self):
"""
return np.array(self.bbox_inches.p1)

def get_size_cm(self):
return np.array(self.bbox_inches.p1)*2.54

def get_edgecolor(self):
'Get the edge color of the Figure rectangle'
return self.patch.get_edgecolor()
Expand Down Expand Up @@ -1792,4 +1798,4 @@ def figaspect(arg):
newsize = np.clip(newsize, figsize_min, figsize_max)
return newsize

docstring.interpd.update(Figure=martist.kwdoc(Figure))
docstring.interpd.update(Figure=martist.kwdoc(Figure))