8000 Hint at draw_without_rendering() in Text.get_window_extent · matplotlib/matplotlib@9477aae · GitHub
[go: up one dir, main page]

Skip to content
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

Appearance settings

Commit 9477aae

Browse files
committed
Hint at draw_without_rendering() in Text.get_window_extent
1 parent d6ed6ce commit 9477aae

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/matplotlib/text.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,9 @@ def get_window_extent(self, renderer=None, dpi=None):
882882
A renderer is needed to compute the bounding box. If the artist
883883
has already been drawn, the renderer is cached; thus, it is only
884884
necessary to pass this argument when calling `get_window_extent`
885-
before the first `draw`. In practice, it is usually easier to
886-
trigger a draw first (e.g. by saving the figure).
885+
before the first draw. In practice, it is usually easier to
886+
trigger a draw first, e.g. by calling
887+
`~.Figure.draw_without_rendering` or ``plt.show()``.
887888
888889
dpi : float, optional
889890
The dpi value for computing the bbox, defaults to
@@ -904,7 +905,9 @@ def get_window_extent(self, renderer=None, dpi=None):
904905
if self._renderer is None:
905906
self._renderer = self.figure._cachedRenderer
906907
if self._renderer is None:
907-
raise RuntimeError('Cannot get window extent w/o renderer')
908+
raise RuntimeError(
909+
"Cannot get window extent of text w/o renderer. You likely "
910+
"want to call 'figure.draw_without_rendering()' first.")
908911

909912
with cbook._setattr_cm(self.figure, dpi=dpi):
910913
bbox, info, descent = self._get_layout(self._renderer)

0 commit comments

Comments
 (0)
0