MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _gen_starting_points

Function _gen_starting_points

lib/matplotlib/streamplot.py:730–767  ·  view source on GitHub ↗

Yield starting points for streamlines. Trying points on the boundary first gives higher quality streamlines. This algorithm starts with a point on the mask corner and spirals inward. This algorithm is inefficient, but fast compared to rest of streamplot.

(shape)

Source from the content-addressed store, hash-verified

728
729
730def _gen_starting_points(shape):
731 """
732 Yield starting points for streamlines.
733
734 Trying points on the boundary first gives higher quality streamlines.
735 This algorithm starts with a point on the mask corner and spirals inward.
736 This algorithm is inefficient, but fast compared to rest of streamplot.
737 """
738 ny, nx = shape
739 xfirst = 0
740 yfirst = 1
741 xlast = nx - 1
742 ylast = ny - 1
743 x, y = 0, 0
744 direction = 'right'
745 for i in range(nx * ny):
746 yield x, y
747
748 if direction == 'right':
749 x += 1
750 if x >= xlast:
751 xlast -= 1
752 direction = 'up'
753 elif direction == 'up':
754 y += 1
755 if y >= ylast:
756 ylast -= 1
757 direction = 'left'
758 elif direction == 'left':
759 x -= 1
760 if x <= xfirst:
761 xfirst += 1
762 direction = 'down'
763 elif direction == 'down':
764 y -= 1
765 if y <= yfirst:
766 yfirst += 1
767 direction = 'right'

Callers 1

streamplotFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…