The handling of the internal renderer objects changed in Matplotlib 3.6, and we
haven't adjusted to the new API. Move the existing logic into a helper function
so we can use it consistently, and try calling the new matplotlib API before
falling back to the old logic.
The handling of the internal renderer objects changed in Matplotlib 3.6, and we haven't adjusted to the new API. Move the existing logic into a helper function so we can use it consistently, and try calling the new matplotlib API before falling back to the old logic.
Fixes #291.