26
26
27
27
import threading
28
28
import numpy as np
29
-
29
+ from math import radians , cos , sin
30
30
from matplotlib import verbose , rcParams
31
31
from matplotlib .backend_bases import RendererBase ,\
32
32
FigureManagerBase , FigureCanvasBase
@@ -174,10 +174,10 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
174
174
ox , oy , width , height , descent , font_image , used_characters = \
175
175
self .mathtext_parser .parse (s , self .dpi , prop )
176
176
177
- xd = descent * np . sin (np . deg2rad (angle ))
178
- yd = descent * np . cos (np . deg2rad (angle ))
179
- x = np . round (x + ox + xd )
180
- y = np . round (y - oy + yd )
177
+ xd = descent * sin (radians (angle ))
178
+ yd = descent * cos (radians (angle ))
179
+ x = round (x + ox + xd )
180
+ y = round (y - oy + yd )
181
181
self ._renderer .draw_text_image (font_image , x , y + 1 , angle , gc )
182
182
183
183
def draw_text (self , gc , x , y , s , prop , angle , ismath = False , mtext = None ):
@@ -204,12 +204,12 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
204
204
xo , yo = font .get_bitmap_offset ()
205
205
xo /= 64.0
206
206
yo /= 64.0
207
- xd = - d * np . sin (np . deg2rad (angle ))
208
- yd = d * np . cos (np . deg2rad (angle ))
207
+ xd = - d * sin (radians (angle ))
208
+ yd = d * cos (radians (angle ))
209
209
210
210
#print x, y, int(x), int(y), s
211
211
self ._renderer .draw_text_image (
212
- font , np . round (x - xd + xo ), np . round (y + yd + yo ) + 1 , angle , gc )
212
+ font , round (x - xd + xo ), round (y + yd + yo ) + 1 , angle , gc )
213
213
214
214
def get_text_width_height_descent (self , s , prop , ismath ):
215
215
"""
@@ -254,10 +254,10 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
254
254
Z = np .array (Z * 255.0 , np .uint8 )
255
255
256
256
w , h , d = self .get_text_width_height_descent (s , prop , ismath )
257
- xd = d * np . sin (np . deg2rad (angle ))
258
- yd = d * np . cos (np . deg2rad (angle ))
259
- x = np . round (x + xd )
260
- y = np . round (y + yd )
257
+ xd = d * sin (radians (angle ))
258
+ yd = d * cos (radians (angle ))
259
+ x = round (x + xd )
260
+ y = round (y + yd )
261
261
262
262
self ._renderer .draw_text_image (Z , x , y , angle , gc )
263
263
0 commit comments