Skip to content

wrong bounds checking in streamplot start_points #18898

@d70-t

Description

@d70-t

Bug report

The bounds check for the start_points argument is wrong if the x or y coordinates are not in ascending order:

import matplotlib.pylab as plt
import numpy as np

u = np.ones((2, 2))
v = np.zeros((2, 2))
x = np.array([0, 10])

y = np.array([10, 0])  # (a)
#y = np.array([0, 10])  # (b)

plt.streamplot(x, y, u, v, start_points=[[5, 5]])  # (c)
#plt.streamplot(x, y, u, v)  # (d)

plt.show()

The code results in

ValueError: Starting point (5.0, 5.0) outside of data boundaries

I would have expected that a plot with one streamline is created. The error goes away either if I replace (a) with (b) or if I replace (c) with (d). Thus if start_points are not given, plotting a descending range works totally fine.

Matplotlib version

  • Operating system: macOS 10.15.7
  • Matplotlib version: 3.3.2
  • Matplotlib backend (print(matplotlib.get_backend())): MacOSX
  • Python version: 3.8.6
  • Other libraries: numpy: 1.19.2

Matplotlib has been installed via pip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions