8000 Added an 'api_changes' entry · matplotlib/matplotlib@9cb2946 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9cb2946

Browse files
author
James Evans
committed
Added an 'api_changes' entry
Renamed '_get_unitless_position' to 'get_unitless_position'
1 parent 22e7a33 commit 9cb2946

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Preserve units with Text position
2+
`````````````````````````````````
3+
4+
Previously the 'get_position' method on Text would strip away unit information
5+
even though the units were still present. There was no inherent need to do
6+
this, so it has been changed so that unit data (if present) will be preserved.
7+
Essentially a call to 'get_position' will return the exact value from a call to
8+
'set_position'.
9+
10+
If you wish to get the old behaviour, then you can use the new method called
11+
'get_unitless_position'.

lib/matplotlib/text.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def contains(self, mouseevent):
280280

281281
def _get_xy_display(self):
282282
'get the (possibly unit converted) transformed x, y in display coords'
283-
x, y = self._get_unitless_position()
283+
x, y = self.get_unitless_position()
284284
return self.get_transform().transform_point((x, y))
285285

286286
def _get_multialignment(self):
@@ -536,7 +536,7 @@ def update_bbox_position_size(self, renderer):
536536

537537
trans = self.get_transform()
538538

539-
# don't use self._get_unitless_position here, which refers to text
539+
# don't use self.get_unitless_position here, which refers to text
540540
# position in Text, and dash position in TextWithDash:
541541
posx = float(self.convert_xunits(self._x))
542542
posy = float(self.convert_yunits(self._y))
@@ -877,7 +877,7 @@ def get_horizontalalignment(self):
877877
"""
878878
return self._horizontalalignment
879879

880-
def _get_unitless_position(self):
880+
def get_unitless_position(self):
881881
"Return the unitless position of the text as a tuple (*x*, *y*)"
882882
# This will get the position with all unit information stripped away.
883883
# This is here for convienience since it is done in several locations.
@@ -899,7 +899,7 @@ def get_prop_tup(self):
899899
want to cache derived information about text (e.g., layouts) and
900900
need to know if the text has changed.
901901
"""
902-
x, y = self._get_unitless_position()
902+
x, y = self.get_unitless_position()
903903
return (x, y, self.get_text(), self._color,
904904
self._verticalalignment, self._horizontalalignment,
905905
hash(self._fontproperties),
@@ -958,7 +958,7 @@ def get_window_extent(self, renderer=None, dpi=None):
958958
raise RuntimeError('Cannot get window extent w/o renderer')
959959

960960
bbox, info, descent = self._get_layout(self._renderer)
961-
x, y = self._get_unitless_position()
961+
x, y = self.get_unitless_position()
962962
x, y = self.get_transform().transform_point((x, y))
963963
bbox = bbox.translated(x, y)
964964
if dpi is not None:
@@ -1373,7 +1373,7 @@ def __init__(self,
13731373

13741374
#self.set_bbox(dict(pad=0))
13751375

1376-
def _get_unitless_position(self):
1376+
def get_unitless_position(self):
13771377
"Return the unitless position of the text as a tuple (*x*, *y*)"
13781378
# This will get the position with all unit information stripped away.
13791379
# This is here for convienience since it is done in several locations.
@@ -1418,7 +1418,7 @@ def update_coords(self, renderer):
14181418
with respect to the actual canvas's coordinates we need to map
14191419
back and forth.
14201420
"""
1421-
dashx, dashy = self._get_unitless_position()
1421+
dashx, dashy = self.get_unitless_position()
14221422
dashlength = self.get_dashlength()
14231423
# Shortcircuit this process if we don't have a dash
14241424
if dashlength == 0.0:

0 commit comments

Comments
 (0)
0