Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e21db0b

Browse files
Fix for issue matplotlib#698 reconstruction and update
1 parent 5d0ca1d commit e21db0b

File tree

5 files changed

+881
-777
lines changed

5 files changed

+881
-777
lines changed

‎lib/matplotlib/text.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def get_rotation(rotation):
129129
x float
130130
y float
131131
zorder any number
132+
trans_rotate [True | False]
132133
========================== ===============================================
133134
""")
134135

@@ -197,6 +198,7 @@ def __init__(self,
197198
rotation_mode=None,
198199
usetex=None, # defaults to rcParams['text.usetex']
199200
wrap=False,
201+
trans_rotate=None,
200202
**kwargs
201203
):
202204
"""
@@ -232,6 +234,7 @@ def __init__(self,
232234
linespacing = 1.2 # Maybe use rcParam later.
233235
self._linespacing = linespacing
234236
self.set_rotation_mode(rotation_mode)
237+
self.set_trans_rotate(trans_rotate)
235238
self.update(kwargs)
236239

237240
def update(self, kwargs):
@@ -308,6 +311,19 @@ def set_rotation_mode(self, m):
308311
raise ValueError("Unknown rotation_mode : %s" % repr(m))
309312
self.stale = True
310313

314+
def set_trans_rotate(self, tr):
315+
"""
316+
Set the boolean flag that determines
317+
if the text should be rotated via
318+
transformation or not
319+
"""
320+
self._trans_rotate = bool(tr)
321+
self.stale = True
322+
323+
def get_trans_rotate(self):
324+
"get transform rotation boolean"
325+
return self._trans_rotate
326+
311327
def get_rotation_mode(self):
312328
"get text rotation mode"
313329
return self._rotation_mode
@@ -753,9 +769,16 @@ def draw(self, renderer):
753769
# position in Text, and dash position in TextWithDash:
754770
posx = float(textobj.convert_xunits(textobj._x))
755771
posy = float(textobj.convert_yunits(textobj._y))
772+
posxangle = posx + 1
773+
posyangle = posy
756774
if not np.isfinite(posx) or not np.isfinite(posy):
757775
raise ValueError("posx and posy should be finite values")
758776
posx, posy = trans.transform_point((posx, posy))
777+
transangle = 0
778+
if self.get_trans_rotate():
779+
posxangle, posyangle = trans.transform_point(
780+
(posxangle, posyangle))
781+
transangle = math.atan2(posyangle - posy, posxangle - posx)
759782
canvasw, canvash = renderer.get_canvas_width_height()
760783

761784
# draw the FancyBboxPatch
@@ -768,7 +791,7 @@ def draw(self, renderer):
768791
gc.set_url(textobj._url)
769792
textobj._set_gc_clip(gc)
770793

771-
angle = textobj.get_rotation()
794+
angle = (textobj.get_rotation()+np.rad2deg(transangle)) %360
772795

773796
for line, wh, x, y in info:
774797

871 Bytes
Binary file not shown.
5.08 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /