Open
Labels
API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …Consistency of the matplotlib API, including naming, behavior, defaults, …topic: contour
Description
Bug report
The command contour does not use lw arguments (unlike, e.g., plot), and does not report an error or warning. The linewidths argument works fine. A simple fix is to explicitly look for lw arguments and set linewidths to that. Happy to put in a PR for this, but I wanted to check first.
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
print(mpl.__version__)
fig, axes = plt.subplots(ncols=3)
for ax, lw, arg in zip(axes, [1.0, 4.0, 4.0], ['lw', 'lw', 'linewidths']):
aa = np.random.normal(size=1000)
bb = np.random.normal(size=aa.size)
hist, xe, ye = np.histogram2d(aa, bb)
kw = {arg: lw}
ax.contour(hist, **kw)
ax.set_title('{}: {}'.format(arg, lw))
plt.show()Actual outcome
Matplotlib version
- Matplotlib version: 3.0.2
Metadata
Metadata
Assignees
Labels
API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …Consistency of the matplotlib API, including naming, behavior, defaults, …topic: contour

Activity
timhoffm commentedon Apr 2, 2019
Current master has a warning
UserWarning: The following kwargs were not used by contour: 'lw'.That's at least good enough to no not surpise the user. I'm unclear if we need/want to take further action.
Options are:
lw. But then we need to accept also other Line2D shortnames. And, the current parameter islinewidthsbutLine2Dhaslinewidth.WeatherGod commentedon Apr 2, 2019
timhoffm commentedon Apr 2, 2019
Nope, it's a
QuadContourSet:https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.contour.html
efiring commentedon Apr 15, 2019
I understand and have some sympathy for the consistency argument for allowing abbreviations, but the kwarg names that are accepted now are documented. Given that the master warns if unrecognized kwargs are given, I think that adding kwarg abbreviations for contour (and by extension, all collections) is low priority, if it is even worth the added complexity of code and documentation at all--which I doubt. One could equally argue that having the abbreviations for
plotis a mistake, adding unnecessary complexity and violating the 'preferably only one obvious way' idea of Python.github-actions commentedon Nov 3, 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!
QuLogic commentedon Nov 3, 2023
This has been warning since #7728, which is from 2017. At this point, I wouldn't be against making it a hard error even.
However, now
ContourSetis derived fromCollection, so theoretically, it could start passing any unused keyword arguments down.github-actions commentedon Jun 9, 2025
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!
timhoffm commentedon Jun 10, 2025
Not tested, but
set()claims to acceptlwhttps://matplotlib.org/stable/api/contour_api.html#matplotlib.contour.QuadContourSet.setIf it does, it'd be reasonable that the constructor does too.