-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Hint at draw_without_rendering() in Text.get_window_extent #22122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -882,8 +882,9 @@ def get_window_extent(self, renderer=None, dpi=None): | |||
A renderer is needed to compute the bounding box. If the artist | |||
has already been drawn, the renderer is cached; thus, it is only | |||
necessary to pass this argument when calling `get_window_extent` | |||
before the first `draw`. In practice, it is usually easier to | |||
trigger a draw first (e.g. by saving the figure). | |||
before the first draw. In practice, it is usually easier to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The draw
link would go to Text.draw which is more or less an internal API and not helpful here (at worst the user might try and call that). It's better to not link to anything here.
612a21c
to
9477aae
Compare
trigger a draw first, e.g. by calling | ||
`~.Figure.draw_without_rendering` or ``plt.show()``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saving is usually not a good way to trigger a draw in this case. You'll likely want to modify the figure somehow based on the extent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 50/50 about including plt.show()
as
plt.ion()
for j in range(5):
fig, ax = plt.subplots()
plt.show()
sleep(5)
will not spin the GUI event loop (and hence in some cases not get the actual render to happen) until after the loop is done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but 99.999% of cases, a draw will occur!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a minor comment, but 👍 on it going in as is.
No description provided.