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

Skip to content

FIX: enable extend kwargs with log scale colorbar #10705

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 5 commits into from
Mar 16, 2018

Conversation

JelsB
Copy link
Contributor

@JelsB JelsB commented Mar 7, 2018

PR Summary

The extend keyword did not work when using a logarithmic colorbar. The extended lower contour level was a large negative number by default, which gives NaN when using a logarithm. A simple fix to change this to a very small positive number when using log scale.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related

@jklymak
Copy link
Member

jklymak commented Mar 7, 2018

Thanks for the contribution @JelsB. Is it possibe to add a test for this? i.e. I have a PR that will wipe out the old tick decisions, so it'd be nice if this PR includes a test that makes sure I don't do revert your change inadvertently. lib/matplotlib/tests/test_colorbar.py would be the appropriate file. Bonus points if you don't need an image test, but I'm not sure if thats easy in this case. If you do include an image test please try to put into the new style and drop text if its ok for the test:

@image_comparison(baseline_images=['YourImage'], extensions=['png'], style='mpl20', 
       remove_text=True)

EDIT: (ooops, sorry for the spurious close/reopen)

@jklymak jklymak closed this Mar 7, 2018
@jklymak jklymak reopened this Mar 7, 2018
@JelsB
Copy link
Contributor Author

JelsB commented Mar 7, 2018

@jklymak I'l make a test in the appropriate file. I don't need an image, I just make a data matrix where a logarithmic scale in useful when plotting. But there seems to be a test already test_colorbar_lognorm_extension(), however without any data to actually show that my fix works. I'll extend that one.

@JelsB
Copy link
Contributor Author

JelsB commented Mar 11, 2018

I've added a test case for this fix in lib/matplotlib/tests/test_contour.py instead of lib/matplotlib/tests/test_colorbar.py as it was a kwarg of the function contourf() that wasn't working and not from the colorbar. I've also added the compare image. Everything works for me when I run py.test test_contour.py::test_contourf_log_extension

@jklymak
Copy link
Member

jklymak commented Mar 15, 2018

@JelsB unfortunately this is failing on the image tests. Likely your test images are using an incompatible free type version.

I think you can add to the image comparison method remove_text=True, style=mpl20 (search te code base for the exact syntax) and that should make it so that font errors are not causing the failure. You’ll have to change the test image...

@JelsB
Copy link
Contributor Author

JelsB commented Mar 15, 2018

I've changed it. I didn't know it matters, some of the already existing test don't have this either.
Let's see if it passes the tests now.

@jklymak
Copy link
Member

jklymak commented Mar 15, 2018

@JelsB We can't merge tests that don't pass. If you make the test image w/ the incorrect version of FreeType, and they have text in them, they will fail.

Your new images are fine, and passing the tests. However, you still have some style (PEP8) issues. Drill down in the travis-ci python 3.6 test to find them.

This should be squashed before merging to make sure only one of the images makes it into the Repo.

Thanks for your patience with the process!

@JelsB
Copy link
Contributor Author

JelsB commented Mar 15, 2018

@jklymak Okay, yes I see the problem. I forgot to check that all of my code has exactly the PEP8 style. I'll fix them. No problem, thanks for guiding me.

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

modulo PEP8

@jklymak jklymak added this to the v3.0 milestone Mar 15, 2018
@timhoffm timhoffm merged commit 95497a6 into matplotlib:master Mar 16, 2018
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.

3 participants