@@ -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