8000 add __eq__ to `matplotlib.gridspec.SubplotSpec` · matplotlib/matplotlib@f328498 · GitHub
[go: up one dir, main page]

Skip to content

Commit f328498

Browse files
committed
add __eq__ to matplotlib.gridspec.SubplotSpec
This is to address the issue discovered in http://stackoverflow.com/questions/20017314/how-are-existing-subplot-axes-retrieved-using-subplot2grid-gridspec-in-matplotli where multiple calls to gs = gridspec.GridSpec(2, 1) ax1 = fig.add_subplot(gs[0, 0]) ax2 = fig.add_subplot(gs[0, 0]) will return a new axes each time (unlike calls integers or tuples).
1 parent 66647b0 commit f328498

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/matplotlib/gridspec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,8 @@ def get_topmost_subplotspec(self):
457457
return gridspec.get_topmost_subplotspec()
458458
else:
459459
return self
460+
461+
def __eq__(self, other):
462+
return all((self._gridspec == other._gridspec,
463+
self.num1 == other.num1,
464+
self.num2 == other.num2))

0 commit comments

Comments
 (0)
0