Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

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

Sign up
Appearance settings

FIX: fallback text renderer to fig._cachedRenderer, if none found#12012

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

jklymak
Copy link
Member

PR Summary

Closes#10874. See also#11004, and#10881. This is a more general backstop than the ticking fixes being proposed in#10874.

If a text obejct is created, but never drawn, its renderer never gets set (self._renderer). Subsequnet calls toself.get_window_extent() that do not specify the renderer fail withRuntimeError('Cannot get window extent w/o renderer').

Here I propose that we fall back on the cached renderer for the figure.

Test code:

import matplotlibmatplotlib.use('Agg')import matplotlib.pyplot as pltfig = plt.figure()ax = fig.add_subplot(111, frameon=True)ax.plot()plt.get_current_fig_manager().canvas.draw()for xtick in ax.get_xticklabels():    bb = xtick.get_window_extent()

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymakjklymak added this to thev2.2.4 milestoneSep 4, 2018
@jklymak
Copy link
MemberAuthor

Milestoning for backporting, because this actually fixes a regression...

@anntzer
Copy link
Contributor

anntzer commentedSep 5, 2018
edited
Loading

I guess this runs afoul of#11971 (comment), but OTOH I can't think of anything better right now.
Edit: it probably doesn't matter anyways (as in "we're already doing it wrong"), see comment on that thread.

@tacaswelltacaswell merged commit10ffa53 intomatplotlib:masterSep 10, 2018
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestSep 10, 2018
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestSep 10, 2018
QuLogic added a commit that referenced this pull requestSep 10, 2018
…012-on-v2.2.xBackport PR#12012 on branch v2.2.x (FIX: fallback text renderer to fig._cachedRenderer, if none found)
QuLogic added a commit that referenced this pull requestSep 10, 2018
…012-on-v3.0.xBackport PR#12012 on branch v3.0.x (FIX: fallback text renderer to fig._cachedRenderer, if none found)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@efiringefiringefiring approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v2.2.4
Development

Successfully merging this pull request may close these issues.

RuntimeError: Cannot get window extent w/o renderer
4 participants
@jklymak@anntzer@efiring@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp