Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 687af18

Browse files
committed
Add streamplot axes method to plot streamlines
1 parent 912ea58 commit 687af18

3 files changed

Lines changed: 563 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
4+
Y, X = np.mgrid[-3:3:100j, -3:3:100j]
5+
U = -1 - X**2 + Y
6+
V = 1 + X - Y**2
7+
speed = np.sqrt(U*U + V*V)
8+
9+
f, (ax1, ax2) = plt.subplots(ncols=2)
10+
ax1.streamplot(X, Y, U, V)
11+
12+
lw = 5*speed/speed.max()
13+
ax2.streamplot(X, Y, U, V, density=0.6,
14+
color=U, cmap=plt.cm.autumn, linewidth=lw)
15+
16+
plt.show()
17+

lib/matplotlib/axes.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import matplotlib.spines as mspines
3030
import matplotlib.quiver as mquiver
3131
import matplotlib.scale as mscale
32+
import matplotlib.streamplot as mstream
3233
import matplotlib.table as mtable
3334
import matplotlib.text as mtext
3435
import matplotlib.ticker as mticker
@@ -6303,6 +6304,21 @@ def quiver(self, *args, **kw):
63036304
return q
63046305
quiver.__doc__ = mquiver.Quiver.quiver_doc
63056306

6307+
def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None,
6308+
cmap=None, arrowsize=1, arrowstyle='-|>', minlength=0.1,
6309+
integrator='RK4'):
6310+
if not self._hold: self.cla()
6311+
mstream.streamplot(self, x, y, u, v,
6312+
density=density,
6313+
linewidth=linewidth,
6314+
color=color,
6315+
cmap=cmap,
6316+
arrowsize=arrowsize,
6317+
arrowstyle=arrowstyle,
6318+
minlength=minlength,
6319+
integrator=integrator)
6320+
streamplot.__doc__ = mstream.streamplot.__doc__
6321+
63066322
@docstring.dedent_interpd
63076323
def barbs(self, *args, **kw):
63086324
"""

0 commit comments

Comments
 (0)