Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix path_effects to work on text with spaces only #22689

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

Merged
merged 2 commits into from
Mar 25, 2022

Conversation

has2k1
Copy link
Contributor

@has2k1 has2k1 commented Mar 23, 2022

When a line of text contains no visual output (spaces only or empty
newlines), there is no path to create for the effects. So, the data
array for this non-path does not have the commonly expected shape for a
path, so the logic bails with an error.

The solution is, do not try to draw a path when the text string has
only spaces and newlines.

closes #22687

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

When a line of text contains no visual output (spaces only or empty
newlines), there is no path to create for the effects. So, the data
array for this non-path does not have the commonly expected shape for a
path, so the logic bails with an error.

The solution is, do not try to draw a path when the text string has
only spaces and newlines.

closes matplotlib#22687
@tacaswell tacaswell added this to the v3.5.2 milestone Mar 23, 2022
@tacaswell
Copy link
Member

I could also see a case for adjusting the shape check farther down to make 0 length paths pass.

@has2k1
Copy link
Contributor Author

has2k1 commented Mar 24, 2022

I could also see a case for adjusting the shape check farther down to make 0 length paths pass.

I went for a real empty path. I was afraid that blow up elsewhere, but it has worked!

@tacaswell tacaswell merged commit abdc7c4 into matplotlib:main Mar 25, 2022
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Mar 25, 2022
timhoffm added a commit that referenced this pull request Mar 25, 2022
…689-on-v3.5.x

Backport PR #22689 on branch v3.5.x (Fix path_effects to work on text with spaces only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Empty text or text with a newline at either end + path_effects crashes
4 participants