get_window_extent has a renderer argument. Its optional for some methods and required by others. If it is set to None it uses the cached renderer, but that requires a draw to have been executed first. In this case you have no draw, so the call fails.
I'm skeptical this ever worked. If so, can you tell us what version? Maybe the renderer cache has changed in some way.
In the meantime, it is safest to call leg2.get_window_extent(fig.canvas.get_renderer()).
Activity
jklymak commented on Oct 6, 2021
get_window_extent has a renderer argument. Its optional for some methods and required by others. If it is set to None it uses the cached renderer, but that requires a draw to have been executed first. In this case you have no draw, so the call fails.
I'm skeptical this ever worked. If so, can you tell us what version? Maybe the renderer cache has changed in some way.
In the meantime, it is safest to call leg2.get_window_extent(fig.canvas.get_renderer()).
QuLogic commented on Jan 25, 2023
I believe this was fixed by #22745.