MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / get_window_extent

Method get_window_extent

site-packages/matplotlib/text.py:2395–2427  ·  view source on GitHub ↗

Return the `Bbox` bounding the text and arrow, in display units. Parameters ---------- renderer : Renderer, optional A renderer is needed to compute the bounding box. If the artist has already been drawn, the renderer is cached; thus, it is

(self, renderer=None)

Source from the content-addressed store, hash-verified

2393 Text.draw(self, renderer)
2394
2395 def get_window_extent(self, renderer=None):
2396 """
2397 Return the `Bbox` bounding the text and arrow, in display units.
2398
2399 Parameters
2400 ----------
2401 renderer : Renderer, optional
2402 A renderer is needed to compute the bounding box. If the artist
2403 has already been drawn, the renderer is cached; thus, it is only
2404 necessary to pass this argument when calling `get_window_extent`
2405 before the first `draw`. In practice, it is usually easier to
2406 trigger a draw first (e.g. by saving the figure).
2407 """
2408 # This block is the same as in Text.get_window_extent, but we need to
2409 # set the renderer before calling update_positions().
2410 if not self.get_visible():
2411 return Bbox.unit()
2412 if renderer is not None:
2413 self._renderer = renderer
2414 if self._renderer is None:
2415 self._renderer = self.figure._cachedRenderer
2416 if self._renderer is None:
2417 raise RuntimeError('Cannot get window extent w/o renderer')
2418
2419 self.update_positions(self._renderer)
2420
2421 text_bbox = Text.get_window_extent(self)
2422 bboxes = [text_bbox]
2423
2424 if self.arrow_patch is not None:
2425 bboxes.append(self.arrow_patch.get_window_extent())
2426
2427 return Bbox.union(bboxes)
2428
2429 arrow = property(
2430 fget=cbook.deprecated("3.0", message="arrow was deprecated in "

Callers

nothing calls this directly

Calls 6

update_positionsMethod · 0.95
get_visibleMethod · 0.80
unitMethod · 0.45
get_window_extentMethod · 0.45
appendMethod · 0.45
unionMethod · 0.45

Tested by

no test coverage detected