From d2675d4ef2da2715f33228f37bccddf8714d0e23 Mon Sep 17 00:00:00 2001 From: Adrien F Vincent Date: Fri, 1 Jul 2016 21:24:21 +0200 Subject: [PATCH 1/3] Fix docstring --- .../streamplot_demo_start_points.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/images_contours_and_fields/streamplot_demo_start_points.py b/examples/images_contours_and_fields/streamplot_demo_start_points.py index b41def0eb838..dc0b3c4a3ffa 100644 --- a/examples/images_contours_and_fields/streamplot_demo_start_points.py +++ b/examples/images_contours_and_fields/streamplot_demo_start_points.py @@ -1,12 +1,8 @@ """ -Demo of the `streamplot` function. +Demo of the streamplot function with starting points. -A streamplot, or streamline plot, is used to display 2D vector fields. This -example shows a few features of the stream plot function: - - * Varying the color along a streamline. - * Varying the density of streamlines. - * Varying the line width along a stream line. +This example shows how to fix the streamlines that are plotted, by passing +an array of seed points to the `start_points` keyword argument. """ import numpy as np import matplotlib.pyplot as plt From 6f5f34737894504256032da44d1cdd047dfa1905 Mon Sep 17 00:00:00 2001 From: Adrien F Vincent Date: Fri, 1 Jul 2016 21:27:30 +0200 Subject: [PATCH 2/3] Remove index on 'fig0' and 'ax0' (only ones of their kind) --- .../streamplot_demo_start_points.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/images_contours_and_fields/streamplot_demo_start_points.py b/examples/images_contours_and_fields/streamplot_demo_start_points.py index dc0b3c4a3ffa..deea9abc7b28 100644 --- a/examples/images_contours_and_fields/streamplot_demo_start_points.py +++ b/examples/images_contours_and_fields/streamplot_demo_start_points.py @@ -14,13 +14,13 @@ seed_points = np.array([[-2, 0, 1], [-2, 0, 1]]) -fig0, ax0 = plt.subplots() -strm = ax0.streamplot(X, Y, U, V, color=U, linewidth=2, - cmap=plt.cm.autumn, start_points=seed_points.T) -fig0.colorbar(strm.lines) +fig, ax = plt.subplots() +strm = ax.streamplot(X, Y, U, V, color=U, linewidth=2, + cmap=plt.cm.autumn, start_points=seed_points.T) +fig.colorbar(strm.lines) -ax0.plot(seed_points[0], seed_points[1], 'bo') +ax.plot(seed_points[0], seed_points[1], 'bo') -ax0.axis((-3, 3, -3, 3)) +ax.axis((-3, 3, -3, 3)) plt.show() From baaadcfc1fc1983c0e8159527133e42749652ab6 Mon Sep 17 00:00:00 2001 From: Adrien F Vincent Date: Fri, 1 Jul 2016 21:43:53 +0200 Subject: [PATCH 3/3] Same vector field as other examples & more demonstrative seeds --- .../streamplot_demo_start_points.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/images_contours_and_fields/streamplot_demo_start_points.py b/examples/images_contours_and_fields/streamplot_demo_start_points.py index deea9abc7b28..0868ecdfd09e 100644 --- a/examples/images_contours_and_fields/streamplot_demo_start_points.py +++ b/examples/images_contours_and_fields/streamplot_demo_start_points.py @@ -7,12 +7,12 @@ import numpy as np import matplotlib.pyplot as plt -X, Y = (np.linspace(-3, 3, 100), - np.linspace(-3, 3, 100)) +Y, X = np.mgrid[-3:3:100j, -3:3:100j] +U = -1 - X**2 + Y +V = 1 + X - Y**2 -U, V = np.mgrid[-3:3:100j, 0:0:100j] - -seed_points = np.array([[-2, 0, 1], [-2, 0, 1]]) +# 5 points along the first diagonal and a point in the left upper quadrant +seed_points = np.array([[-2, -1, 0, 1, 2, -1], [-2, -1, 0, 1, 2, 2]]) fig, ax = plt.subplots() strm = ax.streamplot(X, Y, U, V, color=U, linewidth=2,