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

Skip to content

Commit 514be13

Browse files
committed
Fix callbacks accumulating bug by using a ScaledTranslation rather
than a callback on dpi change. Fix ScaledTranslation.__repr__ (Thanks Stan West for tracking down and fixing these issues). svn path=/trunk/matplotlib/; revision=5412
1 parent 7419d8a commit 514be13

2 files changed

Lines changed: 3 additions & 13 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,8 @@ def cla(self):
827827
props = font_manager.FontProperties(size=rcParams['axes.titlesize'])
828828

829829

830-
self.titleOffsetTrans = mtransforms.Affine2D().translate(
831-
0.0, 5.0*self.figure.dpi/72.)
830+
self.titleOffsetTrans = mtransforms.ScaledTranslation(
831+
0.0, 5.0 / 72.0, self.figure.dpi_scale_trans)
832832
self.title = mtext.Text(
833833
x=0.5, y=1.0, text='',
834834
fontproperties=props,
@@ -859,16 +859,6 @@ def cla(self):
859859
self.xaxis.set_clip_path(self.axesPatch)
860860
self.yaxis.set_clip_path(self.axesPatch)
861861

862-
self.titleOffsetTrans.clear().translate(
863-
0.0, 5.0*self.figure.dpi/72.)
864-
865-
def on_dpi_change(fig):
866-
self.titleOffsetTrans.clear().translate(
867-
0.0, 5.0*fig.dpi/72.)
868-
869-
self.figure.callbacks.connect('dpi_changed', on_dpi_change)
870-
871-
872862

873863
def clear(self):
874864
'clear the axes'

lib/matplotlib/transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ def __init__(self, xt, yt, scale_trans):
20432043
self._inverted = None
20442044

20452045
def __repr__(self):
2046-
return "ScaledTranslation(%s)" % (self._t)
2046+
return "ScaledTranslation(%s)" % (self._t,)
20472047
__str__ = __repr__
20482048

20492049
def get_matrix(self):

0 commit comments

Comments
 (0)