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

Skip to content

Commit 9d5fc37

Browse files
authored
Merge pull request #11492 from timhoffm/gridpsec-repr
add __repr__ to GridSpecBase
2 parents 9014698 + 6cde4bf commit 9d5fc37

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/matplotlib/gridspec.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ def __init__(self, nrows, ncols, height_ratios=None, width_ratios=None):
4444
self.set_height_ratios(height_ratios)
4545
self.set_width_ratios(width_ratios)
4646

47+
def __repr__(self):
48+
height_arg = (', height_ratios=%r' % self._row_height_ratios
49+
if self._row_height_ratios is not None else '')
50+
width_arg = (', width_ratios=%r' % self._col_width_ratios
51+
if self._col_width_ratios is not None else '')
52+
return '{clsname}({nrows}, {ncols}{optionals})'.format(
53+
clsname=self.__class__.__name__,
54+
nrows=self._nrows,
55+
ncols=self._ncols,
56+
optionals=height_arg + width_arg,
57+
)
58+
4759
def get_geometry(self):
4860
'get the geometry of the grid, e.g., 2,3'
4961
return self._nrows, self._ncols

0 commit comments

Comments
 (0)