8000 Merge pull request #25112 from gokberkgunes/main · matplotlib/matplotlib@1125888 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1125888

Browse files
authored
Merge pull request #25112 from gokberkgunes/main
2 parents c075ce0 + a448c0c commit 1125888

File tree

6 files changed

+15
-2
lines changed

6 files changed

+15
-2
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Streamplot now draws streamlines as one piece if no width or no color variance
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Since there is no need to draw streamlines piece by piece if there is no color
5+
change or width change, now streamplot will draw each streamline in one piece.
6+
7+
The behavior for varying width or varying color is not changed, same logic is
8+
used for these kinds of streamplots.

lib/matplotlib/streamplot.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,13 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
198198
tx += grid.x_origin
199199
ty += grid.y_origin
200200

201-
points = np.transpose([tx, ty]).reshape(-1, 1, 2)
202-
streamlines.extend(np.hstack([points[:-1], points[1:]]))
201+
# Create multiple tiny segments if varying width or color is given
202+
if isinstance(linewidth, np.ndarray) or use_multicolor_lines:
203+
points = np.transpose([tx, ty]).reshape(-1, 1, 2)
204+
streamlines.extend(np.hstack([points[:-1], points[1:]]))
205+
else:
206+
points = np.transpose([tx, ty])
207+
streamlines.append(points)
203208

204209
# Add arrows halfway along each trajectory.
205210
s = np.cumsum(np.hypot(np.diff(tx), np.diff(ty)))
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)
0