Skip to content

Singular keyword arguments in contour don't raise exceptions #1963

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

Open
astrofrog opened this issue Apr 30, 2013 · 6 comments
Open

Singular keyword arguments in contour don't raise exceptions #1963

astrofrog opened this issue Apr 30, 2013 · 6 comments
Labels
API: consistency keep Items to be ignored by the “Stale” Github Action topic: contour

Comments

@astrofrog
Copy link
Contributor

I have confused myself several times (and have seen it happen many times with other people) by something like this not working, but also not raising a warning or exception:

plt.contour(image, color='green', linestyle='dotted')

The fact that the keywords are not plural in this case is quite pedantic, but the real issue is that there are not even any warnings or errors, so users are left having no idea why this doesn't work, and are left frustrated when they do find out.

So I would suggest either:

  • raise an exception for non-used keyword arguments (not ideal because it still makes it very pedantic)
  • emit a warning and fix the keyword to the plural version
  • simply accept the singular keywords and just pass them to the plural ones, raising an error if the plural one is defined too.
@dmcdougall
Copy link
Member

Note that, whatever solution is implemented, we'd have to do this for all the plotting routines that take plural kwargs.

@tacaswell tacaswell added this to the v1.5.x milestone Aug 17, 2014
@petehuang
Copy link
Contributor

petehuang commented Dec 30, 2016

Consistency concern is valid for more than just contour, see the api doc for pyplot http://matplotlib.org/api/pyplot_api.html

  • For color: color and c, color
  • For linestyle: linestyles or linestyle or ls or linestyle or linestyles or dashes
  • For linewidth: linewidths or linewidth or lw or linewidth or linewidths or lw
  • For edgecolor: edgecolor or ec or edgecolor or edgecolors
  • For faceolor: facecolor or fc or facecolor or facecolors

and others, I'm sure

Will require deciding combinations to keep and applying consistently across all. The easiest would be to just take the union of all the currently valid variants across methods for a particular keyword (e.g., edgecolor or edgecolors or ec).

I recommend labeling with Difficulty: Medium and Documentation

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Oct 3, 2017
@QuLogic
Copy link
Member

QuLogic commented Apr 22, 2020

See also #2369 for thoughts on what to do with extra (though not typo'd) keyword arguments.

@github-actions
Copy link

github-actions bot commented Sep 1, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Sep 1, 2023
@jklymak jklymak added keep Items to be ignored by the “Stale” Github Action and removed status: inactive Marked by the “Stale” Github Action labels Sep 1, 2023
@jklymak
Copy link
Member

jklymak commented Sep 1, 2023

I think this is still a valid concern. Probably requires some discussion, however I'd be in favour of aliasing these

@anntzer
Copy link
Contributor

anntzer commented Sep 1, 2023

Now that ContourSet has been modified to actually be an artist, we should just route most kwargs to Artist.set() and let that handle standard aliases and error out as usual on unknown properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: consistency keep Items to be ignored by the “Stale” Github Action topic: contour
Projects
None yet
Development

No branches or pull requests

8 participants