Skip to content
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

Equally spaced x values in Matplotlib streamplot #36

Closed
henry2004y opened this issue Dec 1, 2023 · 1 comment
Closed

Equally spaced x values in Matplotlib streamplot #36

henry2004y opened this issue Dec 1, 2023 · 1 comment
Labels
wontfix This will not be worked on

Comments

@henry2004y
Copy link
Owner

henry2004y commented Dec 1, 2023

For some outputs, drawing streamlines may end up with an error in Matplotlib

ValueError("'x' values must be equally spaced")
  File "C:\Users\hyzho\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py", line 1461,

where the actual check in Matplotlib says

if not np.allclose(np.diff(x), self.width / (self.nx - 1)):
    raise ValueError("'x' values must be equally spaced")

A similar check in Julia would be

all(i -> isapprox(xrange[i+1] - xrange[i], (xrange[end] - xrange[1])/(length(xrange)-1)), eachindex(xrange)[1:end-1])

This is clearly a mismatch between Julia and Numpy, probably for Float32 numbers. Not a big deal, but the error messages are annoying. A quick workaround would be to set the plotinterval value together with plotrange.

@henry2004y henry2004y added the wontfix This will not be worked on label Dec 1, 2023
@henry2004y
Copy link
Owner Author

This has already been fixed by using Float64 to construct ranges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant