FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix IndexError for pyplot.legend() when plotting empty bar chart with label by choyiny · Pull Request #13551 · matplotlib/matplotlib · GitHub

Repository navigation

Fix IndexError for pyplot.legend() when plotting empty bar chart with label - #13551

Merged
jklymak merged 3 commits into
matplotlib:masterfrom
choyiny:13003-empty-bar-fix
Mar 2, 2019
Merged

jklymak merged 3 commits into
matplotlib:masterfrom
choyiny:13003-empty-bar-fix

Conversation

choyiny commented Feb 28, 2019

Copy link
Copy Markdown
Contributor

PR Summary

Resolves #13003. Allows an empty bar chart to be created with a legend.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 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

dstansby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This looks good to me. Could you add a test to make sure this doesn't break again in the future? Just the two lines of code in #13003 inside a new test should be enough.

jklymak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good modulo adding the test

Comment thread lib/matplotlib/tests/test_legend.py Outdated
ax.legend(numpoints=0.5)


@image_comparison(baseline_images=['empty_bar_legend'], extensions=['svg'])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

OK, this is failing because your the baseline image is a different size. But...

  1. try not to use svg for this sort of thing because we just rasterize to png anyway.
  2. we try not to do image comparisons if possible because they are expensive in terms of time and bandwidth. Its my undertstanding this crashed before, so all you need for this to pass is for this not to crash (i.e. a smoketest). Suggest you simply remove the image comaprison

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I would say just get rid of the image comparison and the test image, I think it's good enough to just check the code runs without any errors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you for your comments. I will keep that in mind. In the future, how would I do image comparisons? I created the image using save_fig and it seems to output in a different dimension.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I usually run the tests locally (make sure that in setup.cfg you have compiled so that freetype is local) and then copy the resulting image into the baseline images...

dstansby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Whoever merges please squash-merge

jklymak merged commit a06ed93 into matplotlib:master Mar 2, 2019
choyiny deleted the 13003-empty-bar-fix branch March 2, 2019 22:07
choyiny restored the 13003-empty-bar-fix branch March 2, 2019 22:07
QuLogic added this to the v3.2.0 milestone Mar 3, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndexError thrown by pyplot.legend() when plotting empty bar chart with label

4 participants


Back | FazBrowse Home | New Git URL