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

Skip to content

Commit d8e7aef

Browse files
committed
fix dpi-dependent behavior of text bbox & annotate arrow
svn path=/branches/v0_98_5_maint/; revision=6658
1 parent b472516 commit d8e7aef

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2008-12-17 fix dpi-dependent behavior of text bbox and arrow in annotate
2+
-JJL
3+
14
2008-12-16 Another attempt to fix dpi-dependent behavior of Legend. -JJL
25

36
======================================================================

lib/matplotlib/text.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ def get_bbox_patch(self):
367367

368368

369369
def update_bbox_position_size(self, renderer):
370-
""" Update the location and the size of the bbox. This method
370+
"""
371+
Update the location and the size of the bbox. This method
371372
should be used when the position and size of the bbox needs to
372373
be updated before actually drawing the bbox.
373374
"""
@@ -395,8 +396,8 @@ def update_bbox_position_size(self, renderer):
395396
tr = mtransforms.Affine2D().rotate(theta)
396397
tr = tr.translate(posx+x_box, posy+y_box)
397398
self._bbox_patch.set_transform(tr)
398-
fontsize = renderer.points_to_pixels(self.get_size())
399-
self._bbox_patch.set_mutation_scale(fontsize)
399+
fontsize_in_pixel = renderer.points_to_pixels(self.get_size())
400+
self._bbox_patch.set_mutation_scale(fontsize_in_pixel)
400401
#self._bbox_patch.draw(renderer)
401402

402403
else:
@@ -434,7 +435,8 @@ def _draw_bbox(self, renderer, posx, posy):
434435
tr = mtransforms.Affine2D().rotate(theta)
435436
tr = tr.translate(posx+x_box, posy+y_box)
436437
self._bbox_patch.set_transform(tr)
437-
self._bbox_patch.set_mutation_scale(self.get_size())
438+
fontsize_in_pixel = renderer.points_to_pixels(self.get_size())
439+
self._bbox_patch.set_mutation_scale(fontsize_in_pixel)
438440
self._bbox_patch.draw(renderer)
439441

440442

@@ -1557,6 +1559,7 @@ def update_positions(self, renderer):
15571559

15581560
self.arrow_patch.set_positions((ox0, oy0), (ox1,oy1))
15591561
mutation_scale = d.pop("mutation_scale", self.get_size())
1562+
mutation_scale = renderer.points_to_pixels(mutation_scale)
15601563
self.arrow_patch.set_mutation_scale(mutation_scale)
15611564

15621565
if self._bbox_patch:

0 commit comments

Comments
 (0)