MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / draw_text

Method draw_text

lib/matplotlib/backends/backend_wx.py:226–252  ·  view source on GitHub ↗
(self, gc, x, y, s, prop, angle, ismath=False, mtext=None)

Source from the content-addressed store, hash-verified

224 gc.unselect()
225
226 def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
227 # docstring inherited
228
229 if ismath:
230 s = cbook.strip_math(s)
231 _log.debug("%s - draw_text()", type(self))
232 gc.select()
233 self.handle_clip_rectangle(gc)
234 gfx_ctx = gc.gfx_ctx
235
236 font = self.get_wx_font(s, prop)
237 color = gc.get_wxcolour(gc.get_rgb())
238 gfx_ctx.SetFont(font, color)
239
240 w, h, d = self.get_text_width_height_descent(s, prop, ismath)
241 x = int(x)
242 y = int(y - h)
243
244 if angle == 0.0:
245 gfx_ctx.DrawText(s, x, y)
246 else:
247 rads = math.radians(angle)
248 xo = h * math.sin(rads)
249 yo = h * math.cos(rads)
250 gfx_ctx.DrawRotatedText(s, x - xo, y - yo, rads)
251
252 gc.unselect()
253
254 def new_gc(self):
255 # docstring inherited

Callers

nothing calls this directly

Calls 7

handle_clip_rectangleMethod · 0.95
get_wx_fontMethod · 0.95
selectMethod · 0.80
get_wxcolourMethod · 0.80
unselectMethod · 0.80
get_rgbMethod · 0.45

Tested by

no test coverage detected