8000 rescale x and y for streamplot (if necessary) · psyplot/psy-simple@a3abe8f · GitHub
[go: up one dir, main page]

Skip to content

Commit a3abe8f

Browse files
committed
rescale x and y for streamplot (if necessary)
see matplotlib/matplotlib#12474
1 parent bd12934 commit a3abe8f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

psy_simple/plotters.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import six
22
import re
33
from warnings import warn
4+
from psyplot.warning import PsyPlotRuntimeWarning
45
from abc import abstractproperty, abstractmethod
56
from itertools import chain, starmap, cycle, islice, repeat
67
from pandas import (
@@ -4525,6 +4526,14 @@ def _quiver_plot(self):
45254526

45264527
def _stream_plot(self):
45274528
x, y, u, v = self._get_data()
4529+
dx = (x[-1] - x[0]) / (len(x) - 1)
4530+
dy = (y[-1] - y[0]) / (len(y) - 1)
4531+
if not np.allclose(np.diff(x), dx):
4532+
warn("Rescaling x to be equally spaced!", PsyPlotRuntimeWarning)
4533+
x = x[0] + np.zeros_like(x) + (np.arange(len(x)) * dx)
4534+
if not np.allclose(np.diff(y), dy):
4535+
warn("Rescaling y to be equally spaced!", PsyPlotRuntimeWarning)
4536+
y = y[0] + np.zeros_like(y) + (np.arange(len(y)) * dy)
45284537
self._plot = self.ax.streamplot(x, y, u, v, **self._kwargs)
45294538

45304539
def _get_data(self):

0 commit comments

Comments
 (0)
0