Skip to content

better input validation on fill_between #7510

Closed
@robertsawko

Description

@robertsawko

Hi,

So I am running on Python 3.5.2 and Matplotlib 1.5.3 and everything is installed via OS packet manager on Arch Linux. Here's the code I am having issue with:

from matplotlib.pyplot import figure
from numpy import linspace

fig = figure()
ax = fig.gca()

x = linspace(0, 1).reshape(50, 1)

ax.fill_between(x, x, -x)  # That doesn't work!
ax.fill_between(x[:, 0], x[:, 0], -x[:, 0])  # And that ugliness does!

I've already checked that this is due to where=None setting which constructrs where variable via len function. This seems inadequate in many numpy scenarios as occasionally arrays will pop up with or without second dimension. If they do have a second dimension though the where=None will force the error below.

Traceback (most recent call last):
  File "fill_between_test.py", line 11, in <module>
    ax.fill_between(x, x, -x)  # That doesn't work!
  File "/usr/lib/python3.5/site-packages/matplotlib/__init__.py", line 1819, in inner
    return func(ax, *args, **kwargs)
  File "/usr/lib/python3.5/site-packages/matplotlib/axes/_axes.py", line 4596, in fill_between
    raise ValueError("Argument dimensions are incompatible")
ValueError: Argument dimensions are incompatible

Please advise.

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