Fix IndexError for pyplot.legend() when plotting empty bar chart with label#13551
Fix IndexError for pyplot.legend() when plotting empty bar chart with label#13551jklymak merged 3 commits intomatplotlib:masterfrom
Conversation
jklymak
left a comment
There was a problem hiding this comment.
Looks good modulo adding the test
lib/matplotlib/tests/test_legend.py
Outdated
| ax.legend(numpoints=0.5) | ||
|
|
||
|
|
||
| @image_comparison(baseline_images=['empty_bar_legend'], extensions=['svg']) |
There was a problem hiding this comment.
OK, this is failing because your the baseline image is a different size. But...
- try not to use svg for this sort of thing because we just rasterize to png anyway.
- 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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Whoever merges please squash-merge
PR Summary
Resolves #13003. Allows an empty bar chart to be created with a legend.
PR Checklist