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

Skip to content

Commit d10e486

Browse files
committed
Use super() more in offset boxes.
1 parent cb8c65b commit d10e486

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

lib/matplotlib/legend.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ def __init__(self, legend, use_blit=False, update="loc"):
6868
cbook._check_in_list(["loc", "bbox"], update=update)
6969
self._update = update
7070

71-
DraggableOffsetBox.__init__(self, legend, legend._legend_box,
72-
use_blit=use_blit)
71+
super().__init__(legend, legend._legend_box, use_blit=use_blit)
7372

7473
def finalize_offset(self):
7574
if self._update == "loc":

lib/matplotlib/offsetbox.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def set_figure(self, fig):
205205
----------
206206
fig : `~matplotlib.figure.Figure`
207207
"""
208-
martist.Artist.set_figure(self, fig)
208+
super().set_figure(fig)
209209
for c in self.get_children():
210210
c.set_figure(fig)
211211

@@ -800,7 +800,7 @@ def __init__(self, s,
800800
textprops = {}
801801
textprops.setdefault("va", "baseline")
802802
self._text = mtext.Text(0, 0, s, **textprops)
803-
OffsetBox.__init__(self)
803+
super().__init__()
804804
self._children = [self._text]
805805
self.offset_transform = mtransforms.Affine2D()
806806
self._baseline_transform = mtransforms.Affine2D()
@@ -931,7 +931,7 @@ class AuxTransformBox(OffsetBox):
931931
"""
932932
def __init__(self, aux_transform):
933933
self.aux_transform = aux_transform
934-
OffsetBox.__init__(self)
934+
super().__init__()
935935
self.offset_transform = mtransforms.Affine2D()
936936
# ref_offset_transform makes offset_transform always relative to the
937937
# lower-left corner of the bbox of its children.
@@ -1315,7 +1315,7 @@ def __init__(self, arr,
13151315
**kwargs
13161316
):
13171317

1318-
OffsetBox.__init__(self)
1318+
super().__init__()
13191319
self._dpi_cor = dpi_cor
13201320

13211321
self.image = BboxImage(bbox=self.get_window_extent,
@@ -1782,7 +1782,7 @@ def finalize_offset(self):
17821782

17831783
class DraggableOffsetBox(DraggableBase):
17841784
def __init__(self, ref_artist, offsetbox, use_blit=False):
1785-
DraggableBase.__init__(self, ref_artist, use_blit=use_blit)
1785+
super().__init__(ref_artist, use_blit=use_blit)
17861786
self.offsetbox = offsetbox
17871787

17881788
def save_offset(self):
@@ -1808,7 +1808,7 @@ def get_loc_in_canvas(self):
18081808

18091809
class DraggableAnnotation(DraggableBase):
18101810
def __init__(self, annotation, use_blit=False):
1811-
DraggableBase.__init__(self, annotation, use_blit=use_blit)
1811+
super().__init__(annotation, use_blit=use_blit)
18121812
self.annotation = annotation
18131813

18141814
def save_offset(self):

lib/mpl_toolkits/axes_grid1/anchored_artists.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,9 @@ def __init__(self, transform, loc,
146146
"""
147147
self.drawing_area = AuxTransformBox(transform)
148148

149-
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
150-
child=self.drawing_area,
151-
prop=prop,
152-
frameon=frameon,
153-
**kwargs)
149+
super().__init__(loc, pad=pad, borderpad=borderpad,
150+
child=self.drawing_area, prop=prop, frameon=frameon,
151+
**kwargs)
154152

155153

156154
class AnchoredEllipse(AnchoredOffsetbox):
@@ -212,10 +210,8 @@ def __init__(self, transform, width, height, angle, loc,
212210
self.ellipse = Ellipse((0, 0), width, height, angle)
213211
self._box.add_artist(self.ellipse)
214212

215-
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
216-
child=self._box,
217-
prop=prop,
218-
frameon=frameon, **kwargs)
213+
super().__init__(loc, pad=pad, borderpad=borderpad, child=self._box,
214+
prop=prop, frameon=frameon, **kwargs)
219215

220216

221217
class AnchoredSizeBar(AnchoredOffsetbox):
@@ -355,10 +351,8 @@ def __init__(self, transform, size, label, loc,
355351
align="center",
356352
pad=0, sep=sep)
357353

358-
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
359-
child=self._box,
360-
prop=fontproperties,
361-
frameon=frameon, **kwargs)
354+
super().__init__(loc, pad=pad, borderpad=borderpad, child=self._box,
355+
prop=fontproperties, frameon=frameon, **kwargs)
362356

363357

364358
class AnchoredDirectionArrows(AnchoredOffsetbox):
@@ -559,6 +553,5 @@ def __init__(self, transform, label_x, label_y, length=0.15,
559553
self.p_y = PathPatch(text_path_y, **text_props)
560554
self.box.add_artist(self.p_y)
561555

562-
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
563-
child=self.box,
564-
frameon=frameon, **kwargs)
556+
super().__init__(loc, pad=pad, borderpad=borderpad, child=self.box,
557+
frameon=frameon, **kwargs)

0 commit comments

Comments
 (0)