({{, (RefLink[StreamPlot, paclet:ref/StreamPlot])[{(Subscript[v, x]),(Subscript[v, y])},{x,(Subscript[x, min]),(Subscript[x, max])},{y,(Subscript[y, min]),(Subscript[y, max])}] 
generates a stream plot of the vector field {(Subscript[v, x]),(Subscript[v, y])} as a function of x and y. }, {, (RefLink[StreamPlot, paclet:ref/StreamPlot])[{{(Subscript[v, x]),(Subscript[v, y])},{(Subscript[w, x]),(Subscript[w, y])},…},{x,(Subscript[x, min]),(Subscript[x, max])},{y,(Subscript[y, min]),(Subscript[y, max])}]
generates plots of several vector fields. }, {, (RefLink[StreamPlot, paclet:ref/StreamPlot])[…,{x,y}∈reg]
takes the variables {x,y} to be in the geometric region reg. }})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[StreamPlot, paclet:ref/StreamPlot]) plots streamlines that show the local direction of the vector field at each point.

(RefLink[StreamPlot, paclet:ref/StreamPlot]) by default shows enough streamlines to achieve a roughly uniform density throughout the plot, and shows no background scalar field.

(RefLink[StreamPlot, paclet:ref/StreamPlot]) does not show streamlines at any positions for which the (Subscript[v, i]) etc. do not evaluate to real numbers.

(RefLink[StreamPlot, paclet:ref/StreamPlot]) treats the variables x and y as local, effectively using (RefLink[Block, paclet:ref/Block]).

(RefLink[StreamPlot, paclet:ref/StreamPlot]) has attribute (RefLink[HoldAll, paclet:ref/HoldAll]), and evaluates the (Subscript[v, i]) etc. only after assigning specific numerical values to x and y.

In some cases it may be more efficient to use (RefLink[Evaluate, paclet:ref/Evaluate]) to evaluate the (Subscript[v, i]) etc. symbolically before specific numerical values are assigned to x and y.

(RefLink[StreamPlot, paclet:ref/StreamPlot]) has the same options as (RefLink[Graphics, paclet:ref/Graphics]), with the following additions and changes:

The arguments supplied to functions in (RefLink[RegionFunction, paclet:ref/RegionFunction]) and (RefLink[StreamColorFunction, paclet:ref/StreamColorFunction]) are x, y, (Subscript[v, x]), (Subscript[v, y]), (RefLink[Norm, paclet:ref/Norm])[{(Subscript[v, x]),(Subscript[v, y])}].

OpenersPrimaryExamplesSection(Spacer1)Examples  (151)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Plot the streamlines with arrows for the field {-(x^2)+y-1,x-(y^2)+1}:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3}]

Plot the streamlines with arrows for two fields:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3}]

OpenersExampleSection1(Spacer1)Scope  (21)

OpenersExampleSubsection0(Spacer1)Sampling  (10)

Plot a vector field with streamlines placed with specified densities:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamScale->None, PlotLabel->p, StreamPoints->p],{p,{Coarse, Medium, Automatic, Fine}}]

Plot the streamlines that go through a set of seed points:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamPoints->Tuples[{-1,0,1},2],Epilog->Point[Tuples[{-1,0,1},2]]]

Use both automatic and explicit seeding with styles for explicitly seeded streamlines:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamPoints->{{{{1,0},Red},{{-1,-1},Green},Automatic}}]

Plot streamlines over a specified region:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},RegionFunction->Function[{x,y,vx,vy,n},x y<0]]

Plot multiple vector fields:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3}]

Use a specific number of mesh lines:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->5]

Specify specific mesh lines:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->{{2,4,5}}]

Use (RefLink[Evaluate, paclet:ref/Evaluate]) to evaluate the vector field symbolically before numeric assignment:

StreamPlot[Evaluate[D[Sin[x y],{{x,y}}]],{x,0,1},{y,0,1}]

The domain may be specified by a region:

StreamPlot[{y,-x},{x,y}∈Disk[]]

The domain may be specified by a (RefLink[MeshRegion, paclet:ref/MeshRegion]):

𝒟=MeshRegion[{{0,0},{5,-2},{3,0},{5,2}},Polygon[{1,2,3,4}]];

StreamPlot[{Sin[x],Cos[y]},{x,y}∈𝒟]

OpenersExampleSubsection1(Spacer1)Presentation  (11)

Specify different dashings and arrowheads by setting to (RefLink[StreamScale, paclet:ref/StreamScale]):

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->ToString@s,StreamScale->s],{s,{Automatic,None,Full}}]

Plot the streamlines with arrows colored according to the magnitude of the field:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamColorFunction->Hue]

Apply a variety of streamline styles:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamScale->Full,StreamStyle->s],{s,{"Toothpick","Dart",Directive[Orange,Dashed],Arrowheads[{{0.03,Automatic,Graphics[Circle[]]}}]}}]

Use a theme with axes and a different default color:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotTheme->"Scientific"]

Override the style from the theme:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotTheme->"Scientific",StreamStyle->Black]

Use a named appearance to draw the streamlines:

StreamPlot[{y,-x},{x,-3,3},{y,-3,3},StreamMarkers->"Drop"]

Style the streamlines as well:

StreamPlot[{y,-x},{x,-3,3},{y,-3,3},StreamMarkers->"Drop",StreamStyle->Red]

Plot vectors and streamlines together:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},VectorPoints->10,VectorStyle->Red]

Specify mesh lines with different styles:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->{{{2,Thick},{4,Green},{5,{Thick,Red,Dashed}}}}]

Specify global mesh line styles:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->10,MeshStyle->s],{s,{Red,Thick,Directive[Red,Dashed]}}]

Shade mesh regions cyclically:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->10,MeshShading->{Red,Yellow,Green,None}]

Apply a variety of styles to region boundaries:

regionFn=Function[{x,y,vx,vy,n},4<n<6||0<n<2];

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},RegionFunction->regionFn,BoundaryStyle->b],{b,{Red,Thick,Directive[Red,Dashed]}}]

Add a legend with placeholder text:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotLegends->Automatic]

Use the vector fields as legend labels:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotLegends->"Expressions"]

Use explicit labels for each vector field:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotLegends->{"radial","angular"}]

OpenersExampleSection2(Spacer1)Options  (105)

OpenersExampleSubsection2(Spacer1)AspectRatio  (2)

By default, the aspect ratio is 1:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-2,2},{y,-3,3}]

Set the aspect ratio:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-2,2},{y,-3,3},PlotLabel->a,AspectRatio->a],{a,{Automatic,Full,GoldenRatio}}]

OpenersExampleSubsection3(Spacer1)Background  (1)

Use colored backgrounds:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamStyle->Yellow,FrameStyle->LightGray,Background->Black]

OpenersExampleSubsection4(Spacer1)BoundaryStyle  (2)

By default, region boundaries have no style:

regionFn=Function[{x,y,vx,vy,n},4<n<6||0<n<2];

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},RegionFunction->regionFn,BoundaryStyle->None]

Apply a variety of styles to region boundaries:

regionFn=Function[{x,y,vx,vy,n},4<n<6||0<n<2];

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},RegionFunction->regionFn,BoundaryStyle->b],{b,{Red,Thick,Directive[Red,Dashed]}}]

OpenersExampleSubsection5(Spacer1)EvaluationMonitor  (2)

Show where the vector field function is sampled:

ListPlot[Reap[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},EvaluationMonitor:>Sow[{x,y}]]][[-1,1]]]

Count the number of times the vector field function is evaluated:

Block[{k=0},StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},EvaluationMonitor:>k++];k]

OpenersExampleSubsection6(Spacer1)FrameLabel  (1)

Label the axes:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},FrameLabel->{x,y}]

OpenersExampleSubsection7(Spacer1)Mesh  (5)

By default, no mesh lines are displayed:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->None]

Show the final sampling mesh:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->All]

Use a specific number of mesh lines:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->5]

Specify mesh lines:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->{{2,4,5}}]

Use different styles for different mesh lines:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->{{{2,Thick},{4,Green},{5,{Thick,Red,Dashed}}}}]

OpenersExampleSubsection8(Spacer1)MeshFunctions  (3)

By default, mesh lines correspond to the magnitude of the field:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},MeshFunctions->Function[{x,y,vx,vy,n},n],Mesh->5]

Use the x value as the mesh function:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},MeshFunctions->Function[{x,y,vx,vy,n},x],Mesh->5]

Use mesh lines corresponding to fixed distances from the origin:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},MeshFunctions->Function[{x,y,vx,vy,n},Sqrt[x^2+y^2]],Mesh->5]

OpenersExampleSubsection9(Spacer1)MeshShading  (3)

Use (RefLink[None, paclet:ref/None]) to remove regions:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->10,MeshShading->{Red,None}]

Styles are used cyclically:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->10,MeshShading->{Red,Yellow,Green,None}]

Use indexed colors from (RefLink[ColorData, paclet:ref/ColorData]) cyclically:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->10,MeshShading->ColorData[51,"ColorList"]]

OpenersExampleSubsection10(Spacer1)MeshStyle  (1)

Apply a variety of styles to the mesh lines:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},Mesh->10,MeshStyle->s],{s,{Red,Thick,Directive[Red,Dashed]}}]

OpenersExampleSubsection11(Spacer1)PerformanceGoal  (2)

Generate a higher-quality plot:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PerformanceGoal->"Quality"]

Emphasize performance, possibly at the cost of quality:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PerformanceGoal->"Speed"]

OpenersExampleSubsection12(Spacer1)PlotLegends  (4)

No legends are included, by default:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3}]

Include a legend:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotLegends->{"one","two"}]

Control the placement of the legend:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotLegends->Placed[{"one","two"},Below]]

Use the vector fields as the legend text:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotLegends->"Expressions"]

Use placeholder text:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotLegends->Automatic]

Change the appearance of the legend:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotLegends->SwatchLegend["Expressions",LegendMarkerSize->{40,10}]]

OpenersExampleSubsection13(Spacer1)PlotRange  (8)

The full plot range is used by default:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotRange->Full]

Specify an explicit limit for both x and y ranges:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotRange->2]

Specify an explicit range that applies to both x and y ranges:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotRange->{-1,2.5}]

Specify an explicit x range:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotRange->{{-1,2}}]

Specify an explicit x minimum range:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotRange->{{0,Full}}]

Specify an explicit y range:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotRange->{Full,{0,2}}]

Specify an explicit y maximum range:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotRange->{Full,{Full,5}}]

Specify different x and y ranges:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotRange->{{-2,1.5},{-1,2}}]

OpenersExampleSubsection14(Spacer1)PlotTheme  (2)

Use a theme with simpler ticks and brighter colors:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotTheme->"Web"]

Use a theme with automatic legends and dense streamlines:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotTheme->"Detailed"]

Change the stream styles:

StreamPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotTheme->"Detailed",StreamStyle->{Red,Blue}]

OpenersExampleSubsection15(Spacer1)RegionFunction  (3)

Plot streamlines only over certain quadrants:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},RegionFunction->Function[{x,y,vx,vy,n},x y<0]]

Plot streamlines only over regions where the field magnitude is above a given threshold:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},RegionFunction->Function[{x,y,vx,vy,n},n<6]]

Use any logical combination of conditions:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},RegionFunction->Function[{x,y,vx,vy,n},3<n<6||0<n<2]]

OpenersExampleSubsection16(Spacer1)StreamColorFunction  (5)

Color streamlines according to the norm of the vector field:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamColorFunction->Hue]

Use any named color gradient from (RefLink[ColorData, paclet:ref/ColorData]):

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamColorFunction->"Rainbow"]

Use (RefLink[ColorData, paclet:ref/ColorData]) for predefined color gradients:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamColorFunction->Function[{x,y,vx,vy,n},ColorData["AvocadoColors"][x y]]]

Specify a color function that blends two colors by the x coordinate:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamColorFunction->Function[{x,y,vx,vy,n},Blend[{Blue,Red},x]]]

Use (RefLink[StreamColorFunctionScaling, paclet:ref/StreamColorFunctionScaling])->(RefLink[False, paclet:ref/False]) to get unscaled values:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamColorFunctionScaling->False,StreamColorFunction->Function[{x,y,vx,vy,n},ColorData[22][Round[n]]]]

OpenersExampleSubsection17(Spacer1)StreamColorFunctionScaling  (4)

By default, scaled values are used:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamColorFunction->Function[{x,y,vx,vy,n},Blend[{Blue,Red},x]]]

Use (RefLink[StreamColorFunctionScaling, paclet:ref/StreamColorFunctionScaling])->(RefLink[False, paclet:ref/False]) to get unscaled values:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamColorFunctionScaling->False,StreamColorFunction->Function[{x,y,vx,vy,n},ColorData[22][Round[n]]]]

Use unscaled coordinates in the x direction and scaled coordinates in the y directions:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamColorFunction->Function[{x,y,vx,vy,n},Hue[x,y,1]],StreamColorFunctionScaling->{False,True}]

Explicitly specify the scaling for each color function argument:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamColorFunction->Function[{x,y,vx,vy,n},Hue[n,y,1]],StreamColorFunctionScaling->{True,True,True,True,False}]

OpenersExampleSubsection18(Spacer1)StreamMarkers  (3)

Streamlines are drawn as arrows by default:

StreamPlot[{y,-x},{x,-3,3},{y,-3,3}]

Use a named appearance to draw the streamlines:

StreamPlot[{y,-x},{x,-3,3},{y,-3,3},StreamMarkers->"Drop"]

Use different markers for different vector fields:

StreamPlot[{{y,-x},{x,y}},{x,-3,3},{y,-3,3},StreamScale->Large,StreamPoints->Coarse,StreamMarkers->{"Drop","Dart"}]

OpenersExampleSubsection19(Spacer1)StreamPoints  (6)

Specify a specific maximum number of streamlines:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamPoints->10]

Use symbolic names to specify the number of streamlines:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamPoints->p,PlotLabel->p],{p,{Automatic,Coarse,Fine}}]

Use both automatic and explicit seeding with styles for explicitly seeded streamlines:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamPoints->{{{{1,0},Red},{{-1,-1},Green},Automatic}}]

Specify the minimum distance between streamlines:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->d,StreamPoints->{Automatic,d}],{d,{Automatic,1,Scaled[0.05]}}]

Specify the minimum distance between streamlines at the start and end of a streamline:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->d,StreamPoints->{Automatic,d}],{d,{Automatic,{Scaled[0.1],Scaled[0.5]}}}]

Control the maximum length that each streamline can have:

points = Tuples[{-1,0,1},2]

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamPoints->{points,Automatic,maxlen},Epilog->Point[points]],{maxlen,{2.5,Scaled[0.2]}}]

OpenersExampleSubsection20(Spacer1)StreamScale  (9)

Create full streamlines without segmentation:

StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},StreamPoints->10,StreamScale->Full]

Use curves for streamlines:

StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},StreamPoints->10,StreamScale->None]

Use symbolic names to control the lengths of streamlines:

Table[StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->s,StreamScale->s],{s,{Tiny,Large}}]

Specify segment lengths:

Table[StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->s,StreamScale->s],{s,{0.1,0.2,0.4}}]

Specify an explicit dashing pattern for streamlines:

StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},StreamScale->{{0.1,0.1},Automatic}]

Specify the number of points rendered on each streamline segment:

Table[StreamPlot[{y,-x},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->n,StreamScale->{Full,n}],{n,{12,24,All}}]

Specify absolute aspect ratios relative to the longest line segment:

Table[StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},StreamPoints->10,PlotLabel->a,StreamScale->{Automatic,Automatic,a}],{a,{.02,.04}}]

Specify relative aspect ratios relative to each line segment:

Table[StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},StreamPoints->10,PlotLabel->a,StreamScale->{Automatic,Automatic,a}],{a,{Scaled[0.5],Scaled[1],Scaled[1.5]}}]

Scale the length of the arrows by the y coordinate:

StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},StreamScale->{Automatic,2,Automatic,Function[{x,y,vx,vy,n},y]}]

OpenersExampleSubsection21(Spacer1)StreamStyle  (8)

Apply a variety of styles to the streamlines:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamScale->Full,StreamStyle->s],{s,{Orange,Thick,Directive[Orange,Dashed]}}]

Specify a custom arrowhead:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamScale->Full,StreamStyle->Arrowheads[{{0.03,Automatic,Graphics[Circle[]]}}]]

Set the style for multiple vector fields:

StreamPlot[{{-1-x^2+y,1+x-y^2},{-(1+x-y^2),-1-x^2+y}},{x,-3,3},{y,-3,3},StreamPoints->30,VectorStyle->{Red,Blue}]

Use named styles:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->s,StreamScale->{Full,All,0.05},StreamStyle->s],{s,{"Segment","Line"}}]

Named arrow styles:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->s,StreamScale->{Full,All,0.05},StreamStyle->s],{s,{"Arrow","ArrowArrow","CircleArrow"}}]

Named dot styles:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->s,StreamScale->{Full,All,0.03},StreamStyle->s],{s,{"BarDot","Dot","DotArrow","DotDot"}}]

Named pointer styles:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->s,StreamScale->{Full,All,0.03},StreamStyle->s],{s,{"Drop","BackwardPointer","Pointer","Toothpick"}}]

Named dart styles:

Table[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->s,StreamScale->{Full,All,0.03},StreamStyle->s],{s,{"Dart","PinDart","DoubleDart"}}]

OpenersExampleSubsection22(Spacer1)VectorColorFunction  (4)

Color the vectors according to their norms:

StreamPlot[{y,-x },{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorColorFunction->Hue]

Use any named color gradient from (RefLink[ColorData, paclet:ref/ColorData]):

StreamPlot[{y,-x },{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorColorFunction->"DarkRainbow"]

Color the vectors according to their x values:

StreamPlot[{y,-x },{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorColorFunction->Function[{x,y,vx,vy,n},ColorData["ThermometerColors"][x]]]

Use (RefLink[VectorColorFunctionScaling, paclet:ref/VectorColorFunctionScaling])->(RefLink[False, paclet:ref/False]) to get unscaled values:

StreamPlot[{y,-x },{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorColorFunction->Function[{x,y,vx,vy,n},ColorData[22][Round[n]]],VectorColorFunctionScaling->False]

OpenersExampleSubsection23(Spacer1)VectorColorFunctionScaling  (4)

By default, scaled values are used:

StreamPlot[{y,-x },{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorColorFunction->GrayLevel]

Use (RefLink[VectorColorFunctionScaling, paclet:ref/VectorColorFunctionScaling])->(RefLink[False, paclet:ref/False]) to get unscaled values:

StreamPlot[{y,-x },{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorColorFunction->Function[{x,y,vx,vy,n},ColorData[22][Round[n]]],VectorColorFunctionScaling->False]

Use unscaled coordinates in the x direction and scaled coordinates in the y direction:

StreamPlot[{y,-x },{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->10,VectorColorFunction->Function[{x,y,vx,vy,n},Hue[x,y,1]],VectorColorFunctionScaling->{False,True}]

Explicitly specify the scaling for each color function argument:

StreamPlot[{y,-x },{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorColorFunction->Function[{x,y,vx,vy,n},Hue[n,y,1]],VectorColorFunctionScaling->{True,True,True,True,False}]

OpenersExampleSubsection24(Spacer1)VectorPoints  (7)

Use automatically determined vector points:

StreamPlot[{y,-x},{x,-2,2},{y,-2,2},StreamStyle->LightGray,VectorPoints->8,VectorPoints->Automatic]

Use symbolic names to specify the set of field vectors:

Table[StreamPlot[{y,-x},{x,-2,2},{y,-2,2},StreamStyle->LightGray,PlotLabel->k,VectorPoints->k],{k,{Fine,Coarse}}]

Create a regular grid of field vectors with the same number of arrows for x and y:

StreamPlot[{y,-x},{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->5]

Create a regular grid of field vectors with a different number of arrows for x and y:

StreamPlot[{y,-x},{x,-3,3},{y,-3,3}, StreamStyle->LightGray,VectorPoints->{4,7}]

Specify a list of points for showing field vectors:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->RandomReal[{-3,3},{300,2}],VectorScale->Large]

Use a different number of field vectors on a regular grid:

Table[StreamPlot[{y^2,x^2-y^2},{x,-3,3},{y,-3,3},PlotLabel->n,StreamStyle->LightGray,VectorPoints->n,VectorScale->Medium],{n,5,20,5}]

The location for vectors is given in the middle of the drawn vector:

points = {{-1,-1},{-1,1},{1,-1},{1,1}};

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-2,2},{y,-2,2},StreamStyle->LightGray,VectorPoints->points,VectorScale->.25,Epilog->{Red,PointSize[Medium],Point[points]}]

OpenersExampleSubsection25(Spacer1)VectorScale  (9)

Use automatically determined vector scales:

StreamPlot[{y,-x},{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorScale->Automatic]

Specify the relative size of vectors as a fraction of the diagonal of the plot range:

Table[StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},StreamStyle->LightGray,VectorPoints->10,PlotLabel->s,VectorScale->s],{s,{0.05,0.1}}]

Use symbolic names to control the size of vectors:

Table[StreamPlot[{y,-x},{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorScale->s,PlotLabel->s],{s,{Tiny,Small,Medium,Large}}]

With the vector scaling function set to (RefLink[None, paclet:ref/None]), all vectors have the same size:

Table[StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->ToString[f],StreamStyle->LightGray,VectorPoints->8,VectorScale->{Automatic,Automatic,f}],{f,{None,Automatic}}]

Specify an absolute size for the arrowheads:

StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},StreamStyle->LightGray,VectorPoints->8,VectorScale->{Large,1}]

Specify arrowhead size relative to the length of the arrow:

StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},StreamStyle->LightGray,VectorPoints->8,VectorScale->{Large,Scaled[1]}]

Scale the vector length by the absolute value of the x coordinate:

StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},StreamStyle->LightGray,VectorPoints->8,VectorScale->{Large,Automatic,#1&}]

By default, the vector length is scaled by the norm of the vector field:

Table[StreamPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->len,StreamStyle->LightGray,VectorPoints->8,VectorScale->{Large, Automatic, len}],{len,{Automatic,#5&}}]

Scale the vector length by the x component of the vector field:

StreamPlot[{1/(x^2+y^2),1/(x^2+y^2)},{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorScale->{Automatic,Automatic,#},PlotLabel->HoldForm[#]]& /@ {None,Function[If[#5>1,None,#5]]}

OpenersExampleSubsection26(Spacer1)VectorStyle  (7)

Set the style for the vectors:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorStyle->Red]

Set the style for multiple vector fields:

StreamPlot[{{-1-x^2+y,1+x-y^2},{-(1+x-y^2),-1-x^2+y}},{x,-3,3},{y,-3,3},StreamPoints->Coarse,StreamStyle->{Orange,Gray},VectorPoints->8,VectorStyle->{Red,Blue}]

Plot the vector fields without arrowheads:

StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamStyle->LightGray,VectorPoints->8,VectorStyle->Arrowheads[0]]

Use (RefLink[Arrowheads, paclet:ref/Arrowheads]) to specify an explicit style of the arrowheads:

StreamPlot[{x,y},{x,-1,1},{y,-1,1},StreamStyle->LightGray,VectorPoints->8,PlotRange->All,VectorStyle->Arrowheads[{{0.03,Automatic,Graphics[Circle[]]}}]]

Specify both arrow tail and head:

StreamPlot[{x,y},{x,-1,1},{y,-1,1},StreamStyle->LightGray,VectorPoints->8,PlotRange->All, VectorStyle->Arrowheads[{{0.03,Automatic,Graphics[Rectangle[{-0.5,-0.5},{0.5,0.5}]]},{0.03,Automatic,Graphics[Circle[]]}}]]

Graphics primitives without (RefLink[Arrowheads, paclet:ref/Arrowheads]) are scaled based on the vector scale:

StreamPlot[{x,y},{x,-1,1},{y,-1,1},StreamStyle->LightGray,VectorPoints->8,PlotRange->All, VectorStyle->Graphics[Circle[]]]

Change the scaling using the (RefLink[VectorScale, paclet:ref/VectorScale]) option:

StreamPlot[{x,y},{x,-1,1},{y,-1,1},StreamStyle->LightGray,VectorPoints->8,PlotRange->All, VectorStyle->Graphics[Circle[]], VectorScale->{Automatic,Scaled[0.3]}]

OpenersExampleSection3(Spacer1)Applications  (17)

Streamlines for the gradient field of sin(x,y) over the unit square:

StreamPlot[Evaluate[D[Sin[x y],{{x,y}}]],{x,0,1},{y,0,1},StreamScale->Large]

Streamlines for the Hamiltonian vector field of sin(x y):

StreamPlot[Evaluate@{D[Sin[x y],{y}],-D[Sin[x y],{x}]}, {x, 0, 2Pi}, {y, 0, 2Pi},StreamScale->Large]

Streamlines for the Pólya vector field of (z^4)-1:

StreamPlot[Evaluate@{Re[(x+I*y)^4-1],-Im[(x+I*y)^4-1]}, {x, 0, 3}, {y, 0, 3},StreamScale->Large]

Global attractor of damped conservative system:

StreamPlot[{y,-y+x-x^3},{x,-3,3},{y,-3,3},StreamScale->Large]

Combine several examples into a tabbed view:

fields=({{"positive invariant set", {y,-x+y(1-x^2-2y^2)}}, {"structurally stable system", {2x+y-x(x^2+y^2),-y-y(x^2+y^2)}}, {"transcritical bifurcation", {x^2,-y}}, {"reaction-diffusion", {2(y-x)+x(1-x^2),-2(y-x)+y(1-y^2)}}, {"Duffing's equation", {y,x-x^3}}});

fieldIcon[f_]:=Image[StreamPlot[f,{x,-3,3},{y,-3,3},Axes->False,Frame->False,StreamPoints->20],ImageSize->40]

Mouse over the tabs to get a description of the vector field:

TabView[Table[Tooltip[fieldIcon[f[[2]]],f[[1]]]->StreamPlot[f[[2]],{x,-3,3},{y,-3,3},StreamScale->0.2,PlotLabel->TraditionalForm[Column@f[[2]]]],{f,fields}]]

Quadratic system with two limit cycles:

p[x_,y_]:=169(x-1)^2-16(y-1)^2-153;
q[x_,y_]:=144(x-1)^2-9(y-1)^2-135;

With[{λ=0.8},StreamPlot[Evaluate@{p[x,y]Cos[λ]-q[x,y]Sin[λ],p[x,y]Sin[λ]+q[x,y]Cos[λ]},{x,-1,3},{y,-1,3},StreamScale->Large,PlotLabel->Row[{"λ = ",λ}]]]

Van der Pol oscillator:

Table[StreamPlot[{y,-x+λ(1-x^2)y},{x,-3,3},{y,-3,3},PlotLabel->Row[{"λ = ",λ}],StreamScale->Large],{λ,{-1,0,1,5}}]

Characterize linear planar systems interactively:

Manipulate[Row[{Text["m"]==MatrixForm[m],StreamPlot[Evaluate[m.{x,y}],{x,-1,1},{y,-1,1}, StreamScale->Large, StreamColorFunction->"Rainbow",ImageSize->Small]}],{{m,(({{1, 0}, {0, 2}}))}, {(({{1, 0}, {0, 2}}))->"Nodal source",(({{1, 1}, {0, 1}}))->"Degenerate source",(({{0, 1}, {-1, 1}}))->"Spiral source",(({{-1, 0}, {0, -2}}))->"Nodal sink",(({{-1, 1}, {0, -1}}))->"Degenerate sink",(({{0, 1}, {-1, -1}}))->"Spiral sink",(({{0, 1}, {-1, 0}}))->"Center",(({{1, 0}, {0, -2}}))->"Saddle"}}]

Use a stream plot as a background for an interactive differential equation:

splot = StreamPlot[{y,-Sin[x]-.25 y},{x,-4,4},{y,-3,3}];
Manipulate[Show[splot,
ParametricPlot[Evaluate[First[{x[t],y[t]} /. NDSolve[{x'[t]==y[t],y'[t]==-Sin[x[t]]-.25y[t],Thread[{x[0],y[0]}==point]},{x,y},{t,0,T}]]],{t,0,T},PlotStyle->Red]],
{{T,10},1,100},{{point,{1,0}},Locator}, SaveDefinitions->True]

Unfolding a double zero eigenvalue:

f1[x_,y_]:={y,λ1+λ2 x+y^2+x y};

Grid@Table[StreamPlot[Evaluate@f1[x,y],{x,-3,3},{y,-3,3},StreamScale->Large,PlotLabel->Row[{"λ1 = ",λ1, "    λ2 = ",λ2}]],{λ1,{-1,0,1}},{λ2,{-1,0,1}}]

Rotating pendulum:

Manipulate[StreamPlot[{y,(Cos[x]-λ)Sin[x]},{x,-3,3},{y,-3,3},StreamScale->Large,PlotLabel->Row[{"λ = ",λ}]],{λ,-5,5}]

A two-parameter potential:

Manipulate[StreamPlot[{y,-λ-μ x + x^3},{x,-3,3},{y,-3,3},StreamScale->Large,PlotLabel->Row[{"λ = ",λ, " ,  μ = ",μ}]],{λ,-1,1},{μ,-1,1}]

Unfolding the elliptic umbilic:

Manipulate[StreamPlot[Evaluate[-D[1/6y^3-1/2x^2 y+λ1 x+λ2 y+λ3 (x^2+y^2),{{x,y}}]],{x,-3,3},{y,-3,3},StreamScale->Large,PlotLabel->{λ1,λ2,λ3}],{λ1,-1,1},{λ2,-1,1},{λ3,-1,1}]

Generate a list of rasterized stream plots for animation:

labeledImage[g_,λ_]:=Row[{Image[g,ImageSize->175],Row[{" λ = ",λ}]}]

options={StreamScale->Large,StreamStyle->"BackwardPointer"};

g=Table[labeledImage[StreamPlot[{-(x Sin[λ]+y Cos[λ])+(1-x^2-y^2)^2(x Cos[λ]-y Sin[λ]),(x Cos[λ]-y Sin[λ])+(1-x^2-y^2)^2(x Sin[λ]+y Cos[λ])},{x,-3,3},{y,-3,3},Evaluate@options],λ],{λ,0,2π,π/16}];

Animating a list of rasters instead of the original vector graphics may reduce memory usage:

ListAnimate[g]

Create an animation that shifts the streamline colors in the direction of the vector norms:

frames=Table[Image[StreamPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamScale->0.03,StreamColorFunction->(Hue[k+#5]&)],ImageSize->175],{k,0,1,0.1}];

ListAnimate[frames]

Explore various streamline styles and scales with several examples:

fields={{x+y^2+y^3,-x+y+y x^2},{x-x y^2+y^3,3y-y x^2+x^3},{(2-x-2y)x,(2-2x-y)y},{y,(1-x^2-y^2)y/20-x},{2 x y,1+x^2-y^2},{y,x-x^2+(1+x)y}};

styles={"Arrow","ArrowArrow","CircleArrow","BarDot","Dot","DotDot","DotArrow","Dart","Drop","BackwardPointer","Pointer","Toothpick","Dart","PinDart","DoubleDart","Segment","Line"};

Generate icons to graphically represent field choices:

icons=Table[f->Image[StreamPlot[f,{x,-3,3},{y,-3,3},Axes->False,Frame->False,StreamPoints->20,StreamStyle->"Line"],ImageSize->42],{f,fields}];

Click on the field icons to switch field plots:

Manipulate[StreamPlot[field,{x,-3,3},{y,-3,3},ImageSize->300,StreamStyle->style,StreamScale->scale,StreamColorFunction->color],{style,styles},{color,ColorData["Gradients"]},{{scale,0.2},0.05,0.5,0.05},{{field,icons[[1,1]]},icons,Setter}]

Generate a list of stream plots of varying λ:

values={-1,0,1};plots=MapIndexed[Function[{λ,i},StreamPlot[{y,λ-x^2},{x,-3,3},{y,-3,3},StreamPoints->16,StreamScale->0.07,StreamStyle->ColorData["SolarColors"][0.3i[[1]]]]],values]

Stack 2D stream plots in 3D:

stackPlots[plots2D:{__Graphics},dh_,o:OptionsPattern[Graphics3D]]:=Graphics3D[MapIndexed[Function[{g,index},g[[1]]/.Arrow[v2d_]:>Arrow[v2d/.{x_?NumericQ,y_?NumericQ}:>{x,y,dh index[[1]]}]],plots2D],o]

plotSpacing=5;
stackPlots[plots,plotSpacing,Axes->True,Boxed->False,Ticks->{Automatic,Automatic,MapIndexed[{plotSpacing#2[[1]],Row[{"λ = ",#1}]}&,values]}]

OpenersExampleSection4(Spacer1)Properties & Relations  (6)

Use (RefLink[ListStreamPlot, paclet:ref/ListStreamPlot]) for plotting data:

data=Table[{-1-x^2+y,1+x-y^2},{x,-3,3,0.2},{y,-3,3,0.2}];

ListStreamPlot[data]

Use (RefLink[StreamDensityPlot, paclet:ref/StreamDensityPlot]) to add a density plot of the scalar field:

StreamDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3}]

Use (RefLink[ListStreamDensityPlot, paclet:ref/ListStreamDensityPlot]) for plotting data with a density plot of the scalar field:

data=Table[{{x,y}=RandomReal[{-1.5,1.5},{2}],{{-1-x^2+y,1+x-y^2},Abs[x+y]}},{300}];

ListStreamDensityPlot[data,ColorFunction->"Pastel"]

Use (RefLink[VectorPlot, paclet:ref/VectorPlot]) to plot with vectors instead of streamlines:

VectorPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3}]

Use (RefLink[LineIntegralConvolutionPlot, paclet:ref/LineIntegralConvolutionPlot]) to plot the line integral convolution of a vector field:

LineIntegralConvolutionPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3}]

Use (RefLink[VectorPlot3D, paclet:ref/VectorPlot3D]) to visualize 3D vector fields:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[StreamDensityPlot, paclet:ref/StreamDensityPlot])  ▪  (RefLink[VectorPlot, paclet:ref/VectorPlot])  ▪  (RefLink[ListStreamPlot, paclet:ref/ListStreamPlot])  ▪  (RefLink[LineIntegralConvolutionPlot, paclet:ref/LineIntegralConvolutionPlot])  ▪  (RefLink[ParametricPlot, paclet:ref/ParametricPlot])  ▪  (RefLink[ContourPlot, paclet:ref/ContourPlot])  ▪  (RefLink[DensityPlot, paclet:ref/DensityPlot])  ▪  (RefLink[Plot3D, paclet:ref/Plot3D])  ▪  (RefLink[VectorPlot3D, paclet:ref/VectorPlot3D])  ▪  (RefLink[SliceVectorPlot3D, paclet:ref/SliceVectorPlot3D])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Vector Visualization, paclet:guide/VectorVisualization])}, {▪(RefLinkPlain[Function Visualization, paclet:guide/FunctionVisualization])}, {▪(RefLinkPlain[Vector Analysis, paclet:guide/VectorAnalysis])}, {▪(RefLinkPlain[Differential Equations, paclet:guide/DifferentialEquations])}, {▪(RefLinkPlain[Solvers over Regions, paclet:guide/GeometricSolvers])}})}})