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

Skip to content

Commit 688a889

Browse files
committed
refactor Annotation to support arbitrary transformation.
svn path=/trunk/matplotlib/; revision=8157
1 parent 0e72c7a commit 688a889

3 files changed

Lines changed: 212 additions & 98 deletions

File tree

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2010-02-25 refactor Annotation to support arbitrary Transform as xycoords
2+
or textcoords. Also, if a tuple of two coordinates is provided,
3+
they are interpreted as coordinates for each x and y position.
4+
-JJL
5+
16
2010-02-24 Added pyplot.fig_subplot(), to create a figure and a group of
27
subplots in a single call. This offers an easier pattern than
38
manually making figures and calling add_subplot() multiple times. FP

lib/matplotlib/offsetbox.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,11 +1301,11 @@ def _update_position_xybox(self, renderer, xy_pixel):
13011301
x, y = self.xytext
13021302
if isinstance(self.textcoords, tuple):
13031303
xcoord, ycoord = self.textcoords
1304-
x1, y1 = self._get_xy(x, y, xcoord)
1305-
x2, y2 = self._get_xy(x, y, ycoord)
1304+
x1, y1 = self._get_xy(renderer, x, y, xcoord)
1305+
x2, y2 = self._get_xy(renderer, x, y, ycoord)
13061306
ox0, oy0 = x1, y2
13071307
else:
1308-
ox0, oy0 = self._get_xy(x, y, self.textcoords)
1308+
ox0, oy0 = self._get_xy(renderer, x, y, self.textcoords)
13091309

13101310
#self.offsetbox.set_bbox_to_anchor((ox0, oy0))
13111311
w, h, xd, yd = self.offsetbox.get_extent(renderer)
@@ -1526,11 +1526,11 @@ def save_offset(self):
15261526
x, y = ann.xytext
15271527
if isinstance(ann.textcoords, tuple):
15281528
xcoord, ycoord = ann.textcoords
1529-
x1, y1 = ann._get_xy(x, y, xcoord)
1530-
x2, y2 = ann._get_xy(x, y, ycoord)
1529+
x1, y1 = ann._get_xy(self.canvas.renderer, x, y, xcoord)
1530+
x2, y2 = ann._get_xy(self.canvas.renderer, x, y, ycoord)
15311531
ox0, oy0 = x1, y2
15321532
else:
1533-
ox0, oy0 = ann._get_xy(x, y, ann.textcoords)
1533+
ox0, oy0 = ann._get_xy(self.canvas.renderer, x, y, ann.textcoords)
15341534

15351535
self.ox, self.oy = ox0, oy0
15361536
self.annotation.textcoords = "figure pixels"
@@ -1539,7 +1539,7 @@ def update_offset(self, dx, dy):
15391539
ann = self.annotation
15401540
ann.xytext = self.ox + dx, self.oy + dy
15411541
x, y = ann.xytext
1542-
xy = ann._get_xy(x, y, ann.textcoords)
1542+
xy = ann._get_xy(self.canvas.renderer, x, y, ann.textcoords)
15431543

15441544
def finalize_offset(self):
15451545
loc_in_canvas = self.annotation.xytext

0 commit comments

Comments
 (0)