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

Skip to content

drawstyle accepts anything as default rather than raising #6143

Closed
@madphysicist

Description

@madphysicist

Setup

matplotlib.__version__ = 1.5.1
matplotlib.__version__numpy__ = 1.6
Python 3.5.1, IPython 4.1.2 running under anaconda
OS: Red Hat 6.5

Matplotlib installed with conda install matplotlib.

Issue

Supplying invalid drawstyle parameter to plot (and possible others) does not raise an error. I would expect the following not to work, but it does:

>>> import matplotlib.pyplot as plt
>>> plt.plot(range(5), range(5), drawstyle='mwahahahahaha')

For contrast, trying the same thing with fillstyle raises the expected error:

>>> plt.plot(range(5), range(5), fillstyle='mwahahahahaha')
...
ValueError: Unrecognized fillstyle full left right bottom top none

Notes

The issue seems to be happening here:

if self._drawstyle != drawstyle:
. I would submit a PR, but I am pretty sure that adding something like

drawstyles = ('default', 'steps', 'steps-pre', 'steps-mid', 'steps-post')
if drawstyle not in drawstyles:
    raise ValueError(' '.join(('Unrecognized drawstyle',) + drawstyles))

would mess up something or another. If not, I would be glad to make the change.

To help us understand and resolve your issue please check that you have provided
the information below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions