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

Skip to content

Commit 980620e

Browse files
committed
Merge pull request #5356 from Tillsten/ticker_maint
Replace numpy funcs for scalars.
2 parents 8f6b90e + becda34 commit 980620e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/matplotlib/backends/backend_agg.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import threading
2828
import numpy as np
29-
29+
from math import radians, cos, sin
3030
from matplotlib import verbose, rcParams
3131
from matplotlib.backend_bases import RendererBase,\
3232
FigureManagerBase, FigureCanvasBase
@@ -174,10 +174,10 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
174174
ox, oy, width, height, descent, font_image, used_characters = \
175175
self.mathtext_parser.parse(s, self.dpi, prop)
176176

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)
181181
self._renderer.draw_text_image(font_image, x, y + 1, angle, gc)
182182

183183
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
@@ -205,12 +205,12 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
205205
xo, yo = font.get_bitmap_offset()
206206
xo /= 64.0
207207
yo /= 64.0
208-
xd = -d * np.sin(np.deg2rad(angle))
209-
yd = d * np.cos(np.deg2rad(angle))
208+
xd = -d * sin(radians(angle))
209+
yd = d * cos(radians(angle))
210210

211211
#print x, y, int(x), int(y), s
212212
self._renderer.draw_text_image(
213-
font, np.round(x - xd + xo), np.round(y + yd + yo) + 1, angle, gc)
213+
font, round(x - xd + xo), round(y + yd + yo) + 1, angle, gc)
214214

215215
def get_text_width_height_descent(self, s, prop, ismath):
216216
"""
@@ -255,10 +255,10 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
255255
Z = np.array(Z * 255.0, np.uint8)
256256

257257
w, h, d = self.get_text_width_height_descent(s, prop, ismath)
258-
xd = d * np.sin(np.deg2rad(angle))
259-
yd = d * np.cos(np.deg2rad(angle))
260-
x = np.round(x + xd)
261-
y = np.round(y + yd)
258+
xd = d * sin(radians(angle))
259+
yd = d * cos(radians(angle))
260+
x = round(x + xd)
261+
y = round(y + yd)
262262

263263
self._renderer.draw_text_image(Z, x, y, angle, gc)
264264

0 commit comments

Comments
 (0)