Skip to content
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

Fix figure.colorbar() with axes keywords #10000

Merged
merged 2 commits into from
Dec 18, 2017

Conversation

timhoffm
Copy link
Member

Fixes #8493.

The problem was that Figure.colorbar() accepts Axes as well as Colorbar keywords. However they are all passed on to the Colorbar constructor. This has an explicit signature of supported keywords and complains on the Axes keywords 'anchor' and 'panchor'.

The fix is to filter out Axes keywords that are not allowed in Colorbar. Note: 'orientation' has to be passed to both.

@anntzer
Copy link
Contributor

anntzer commented Dec 14, 2017

Congratulations on getting issue #10000 :-)

@timhoffm
Copy link
Member Author

Thanks!

@jklymak
Copy link
Member

jklymak commented Dec 14, 2017

Can we have a test that checks these kwargs are stripped so no one monkeys w/ this down the road?

@timhoffm
Copy link
Member Author

@jklymak I've added a test. It just checks that the arguments are accepted and do not raise an exception.


# need to remove kws that cannot be passed to Colorbar
NON_COLORBAR_KEYS = ['fraction', 'pad', 'shrink', 'aspect', 'anchor',
'panchor']
Copy link
Member

Choose a reason for hiding this comment

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

Does the remove of these kwargs mean the docstring was wrong/needs changing now?

Copy link
Member Author

@timhoffm timhoffm Dec 18, 2017

Choose a reason for hiding this comment

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

I don't think so. The notes section in the docs says says:

Additional keyword arguments are of two kinds:

  • axes properties
  • colorbar properties

We receive a mixture, which AFAICS is intended. But we have to remove the kwargs, that Colorbar does not understand.

@dstansby dstansby added this to the v2.2 milestone Dec 18, 2017
@dstansby dstansby merged commit c5b70cb into matplotlib:master Dec 18, 2017
@tacaswell tacaswell modified the milestones: v2.2, v2.1.2 Dec 18, 2017
@timhoffm timhoffm deleted the fix-figure-colorbar branch December 19, 2017 23:25
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 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.

Colorbar documentation: anchor not recognized as possible argument to plt.colorbar
6 participants