({{, (RefLink[StreamDensityPlot, paclet:ref/StreamDensityPlot])[{{(Subscript[v, x]),(Subscript[v, y])},s},{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, superimposed on a background density plot of the scalar field s. }, {, (RefLink[StreamDensityPlot, paclet:ref/StreamDensityPlot])[{(Subscript[v, x]),(Subscript[v, y])},{x,(Subscript[x, min]),(Subscript[x, max])},{y,(Subscript[y, min]),(Subscript[y, max])}]
takes the scalar field to be the norm of the vector field.}, {, (RefLink[StreamDensityPlot, paclet:ref/StreamDensityPlot])[{{(Subscript[v, x]),(Subscript[v, y])},{(Subscript[w, x]),(Subscript[w, y])},…,s},{x,(Subscript[x, min]),(Subscript[x, max])},{y,(Subscript[y, min]),(Subscript[y, max])}]
generates plots of several vector fields. }, {, (RefLink[StreamDensityPlot, paclet:ref/StreamDensityPlot])[…,{x,y}∈reg]
takes the variables {x,y} to be in the geometric region reg. }})

OpenersNotesSection(Spacer1)Details and Options

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

(RefLink[StreamDensityPlot, paclet:ref/StreamDensityPlot]) by default shows enough streamlines to achieve a roughly uniform density throughout the plot.

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

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

(RefLink[StreamDensityPlot, paclet:ref/StreamDensityPlot]) 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[StreamDensityPlot, paclet:ref/StreamDensityPlot]) has the same options as (RefLink[Graphics, paclet:ref/Graphics]), with the following additions and changes:

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

The default setting (RefLink[MeshFunctions, paclet:ref/MeshFunctions])->{#5&} draws mesh lines for the scalar field s.

OpenersPrimaryExamplesSection(Spacer1)Examples  (173)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Plot the streamlines for a vector field with background based on field magnitude:

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

Plot the streamlines for a vector field with background based on a logarithm of field magnitude:

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

Plot the streamlines for two fields with a background based on the first field's magnitude:

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

OpenersExampleSection1(Spacer1)Scope  (24)

OpenersExampleSubsection0(Spacer1)Sampling  (11)

Visualize a vector field with the background based on cos (x):

StreamDensityPlot[{{-1-x^2+y,1+x-y^2},Cos[x]},{x,-3,3},{y,-3,3},StreamScale->Large]

Plot two vector fields with background color based on the first field's magnitude:

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

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

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

Plot a vector field with streamlines placed with specified densities:

Table[StreamDensityPlot[{-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:

StreamDensityPlot[{-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:

StreamDensityPlot[{-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:

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

Use a specific number of mesh lines:

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

Specify mesh lines:

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

The domain may be specified by a region:

StreamDensityPlot[{{y,-x},x+y},{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}]];

StreamDensityPlot[{{Sin[x],Cos[y]},(x^2)+(y^2)},{x,y}∈𝒟]

OpenersExampleSubsection1(Spacer1)Presentation  (13)

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

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

Color the background scalar field with a color function:

v={-1-x^2+y,1+x-y^2};
s=Exp[Norm[v]/10];

Table[StreamDensityPlot[f,{x,-3,3},{y,-3,3},ColorFunction->"Pastel"],{f,{v,{v,s}}}]

Plot the streamlines with arrows colored according to field magnitude:

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

Apply a variety of streamline styles:

Table[StreamDensityPlot[{-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 different themes for the plot:

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

Use a named appearance to draw the streamlines:

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

Style the streamlines as well:

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

Plot vectors and streamlines together:

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

Specify mesh lines with different styles:

StreamDensityPlot[{-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[StreamDensityPlot[{-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:

StreamDensityPlot[{-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[StreamDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},RegionFunction->regionFn,BoundaryStyle->b],{b,{Red,Thick,Directive[Red,Dashed]}}]

Fix the lighting angle at 0 (right of the plot), and vary the altitude from 0 to π/2:

Table[StreamDensityPlot[{{y,-x},Sin[x^2+y^2]},{x,-3,3},{y,-3,3},PlotLabel->ϕ,LightingAngle->{0,ϕ},MaxRecursion->3],{ϕ,0,Pi/2,Pi/4}]

Include a legend for the scalar field:

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

OpenersExampleSection2(Spacer1)Options  (118)

OpenersExampleSubsection2(Spacer1)AspectRatio  (2)

By default, the aspect ratio is 1:

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

Set the aspect ratio:

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

OpenersExampleSubsection3(Spacer1)Background  (1)

Use colored backgrounds:

StreamDensityPlot[{-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];

StreamDensityPlot[{-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[StreamDensityPlot[{-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)ColorFunction  (6)

Color the field magnitude using (RefLink[Hue, paclet:ref/Hue]):

StreamDensityPlot[{y,-x},{x,-3,3},{y,-3,3},ColorFunction->Hue]

Color using (RefLink[Hue, paclet:ref/Hue]) based on sin(x y):

StreamDensityPlot[{{y,-x},Sin[x y]},{x,-3,3},{y,-3,3},MaxRecursion->2,ColorFunction->Hue]

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

StreamDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},ColorFunction->"Pastel"]

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

StreamDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},ColorFunction->Function[{x,y,vx,vy,n},ColorData["SolarColors"][x y]]]

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

StreamDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},ColorFunction->Function[{x,y,vx,vy,n},Blend[{Green,Red},x]]]

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

StreamDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},MaxRecursion->4,ColorFunctionScaling->False,ColorFunction->Function[{x,y,vx,vy,n},ColorData[22][Round[n]]]]

OpenersExampleSubsection6(Spacer1)ColorFunctionScaling  (4)

By default, scaled values are used:

StreamDensityPlot[{y Cos[x y],x Cos[x y]},{x,-3,3},{y,-3,3},MaxRecursion->2,ColorFunction->GrayLevel]

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

StreamDensityPlot[{y Cos[x y],x Cos[x y]},{x,-3,3},{y,-3,3},MaxRecursion->4,ColorFunctionScaling->False,ColorFunction->Function[{x,y,vx,vy,n},ColorData[22][Round[n]]]]

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

StreamDensityPlot[{y Cos[x y],x Cos[x y]},{x,-3,3},{y,-3,3},ColorFunctionScaling->{False,True},ColorFunction->Function[{x,y,vx,vy,n},Hue[x,y,1]]]

Explicitly specify the scaling for each color function argument:

StreamDensityPlot[{y Cos[x y],x Cos[x y]},{x,-3,3},{y,-3,3},MaxRecursion->3,ColorFunctionScaling->{True,True,True,True,False},ColorFunction->Function[{x,y,vx,vy,n},Hue[n,y,1]]]

OpenersExampleSubsection7(Spacer1)EvaluationMonitor  (2)

Show where the vector field function is sampled:

ListPlot[Reap[StreamDensityPlot[{-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},StreamDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},EvaluationMonitor:>k++];k]

OpenersExampleSubsection8(Spacer1)FrameLabel  (1)

Label the axes:

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

OpenersExampleSubsection9(Spacer1)LightingAngle  (2)

Vary the lighting angle from 0 (right of the plot) to π/2 (top of the plot):

Table[StreamDensityPlot[{{y,-x},Cos[x^2+y^2]},{x,-3,3},{y,-3,3},PlotLabel->θ,LightingAngle->{θ,0},MaxRecursion->3,Epilog->{Yellow,PointSize[.05],Point[3{Cos[θ],Sin[θ]}]}],{θ,0,Pi,Pi/2}]

Fix the lighting angle at 0 (right of the plot), and vary the altitude from 0 to π/2:

Table[StreamDensityPlot[{{y,-x},Sin[x^2+y^2]},{x,-3,3},{y,-3,3},PlotLabel->ϕ,LightingAngle->{0,ϕ},MaxRecursion->3],{ϕ,0,Pi/2,Pi/4}]

OpenersExampleSubsection10(Spacer1)MaxRecursion  (1)

Refine the plot where it changes quickly:

Table[StreamDensityPlot[{{y,-x},Sin[x y]},{x,-3,3},{y,-3,3},PlotLabel->r,ColorFunction->Hue,MaxRecursion->r],{r,0,2}]

OpenersExampleSubsection11(Spacer1)Mesh  (5)

By default, no mesh lines are displayed:

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

Show the final sampling mesh:

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

Use a specific number of mesh lines:

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

Specify mesh lines:

StreamDensityPlot[{-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:

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

OpenersExampleSubsection12(Spacer1)MeshFunctions  (3)

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

StreamDensityPlot[{-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:

StreamDensityPlot[{-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:

StreamDensityPlot[{-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]

OpenersExampleSubsection13(Spacer1)MeshShading  (3)

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

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

Styles are used cyclically:

StreamDensityPlot[{-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:

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

OpenersExampleSubsection14(Spacer1)MeshStyle  (1)

Apply a variety of styles to the mesh lines:

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

OpenersExampleSubsection15(Spacer1)NormalsFunction  (2)

Do not use normals in shading:

StreamDensityPlot[{Cos[x^2+y],1+x-y^2},{x,-3,3},{y,-3,3},LightingAngle->Pi/4,NormalsFunction->None]

Randomly vary the effective normals:

StreamDensityPlot[{Cos[x^2+y],1+x-y^2},{x,-3,3},{y,-3,3},LightingAngle->Pi/4,NormalsFunction->Function[{x,y,vx,vy,n},RandomReal[{0,1},{3}]]]

OpenersExampleSubsection16(Spacer1)PerformanceGoal  (2)

Generate a higher-quality plot:

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

Emphasize performance, possibly at the cost of quality:

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

OpenersExampleSubsection17(Spacer1)PlotLegends  (3)

No legends are included, by default:

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

Include a legend for the scalar field:

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

Control the placement of the legend:

StreamDensityPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotLegends->Placed[Automatic,Below]]

OpenersExampleSubsection18(Spacer1)PlotRange  (8)

The full plot range is used by default:

StreamDensityPlot[{-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:

StreamDensityPlot[{-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:

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

Specify an explicit x range:

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

Specify an explicit x minimum range:

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

Specify an explicit y range:

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

Specify an explicit y maximum range:

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

Specify different x and y ranges:

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

OpenersExampleSubsection19(Spacer1)PlotTheme  (2)

Use a monochrome theme:

StreamDensityPlot[{x,y},{x,-3,3},{y,-3,3},PlotTheme->"Monochrome"]

Change the stream style:

StreamDensityPlot[{x,y},{x,-3,3},{y,-3,3},PlotTheme->"Monochrome",StreamStyle->White]

OpenersExampleSubsection20(Spacer1)RegionFunction  (3)

Plot streamlines only over certain quadrants:

StreamDensityPlot[{-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:

StreamDensityPlot[{-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:

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

OpenersExampleSubsection21(Spacer1)StreamColorFunction  (5)

Color streamlines according to the norm of the vector field:

StreamDensityPlot[{Sin[x],Cos[y]},{x,-3,3},{y,-3,3},StreamColorFunction->Hue]

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

StreamDensityPlot[{Sin[x],Cos[y]},{x,-3,3},{y,-3,3},StreamColorFunction->"Rainbow"]

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

StreamDensityPlot[{Sin[x],Cos[y]},{x,-3,3},{y,-3,3},StreamColorFunction->Function[{x,y,vx,vy,n},ColorData["RedGreenSplit"][x y]]]

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

StreamDensityPlot[{Sin[x],Cos[y]},{x,-3,3},{y,-3,3},StreamColorFunction->Function[{x,y,vx,vy,n},Blend[{Green,Red},x]]]

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

StreamDensityPlot[{-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]]]]

OpenersExampleSubsection22(Spacer1)StreamColorFunctionScaling  (4)

By default, scaled values are used:

StreamDensityPlot[{Sin[x],Cos[y]},{x,-3,3},{y,-3,3},StreamColorFunction->GrayLevel]

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

StreamDensityPlot[{-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 direction:

StreamDensityPlot[{Sin[x],Cos[y]},{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:

StreamDensityPlot[{Sin[x],Cos[y]},{x,-3,3},{y,-3,3},StreamColorFunction->Function[{x,y,vx,vy,n},Hue[n,y,1]],StreamColorFunctionScaling->{True,True,True,True,False}]

OpenersExampleSubsection23(Spacer1)StreamMarkers  (3)

Streamlines are drawn as arrows by default:

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

Use a named appearance to draw the streamlines:

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

Use different markers for different vector fields:

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

OpenersExampleSubsection24(Spacer1)StreamPoints  (6)

Specify a maximum number of streamlines:

StreamDensityPlot[{-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[StreamDensityPlot[{-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:

StreamDensityPlot[{-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[StreamDensityPlot[{-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[StreamDensityPlot[{-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[StreamDensityPlot[{-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]}}]

OpenersExampleSubsection25(Spacer1)StreamScale  (9)

Create full streamlines without segmentation:

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

Use curves for streamlines:

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

Use symbolic names to control the lengths of streamlines:

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

Specify segment lengths:

Table[StreamDensityPlot[{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:

StreamDensityPlot[{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[StreamDensityPlot[{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[StreamDensityPlot[{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[StreamDensityPlot[{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:

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

OpenersExampleSubsection26(Spacer1)StreamStyle  (8)

Apply a variety of styles to the streamlines:

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

Specify a custom arrowhead:

StreamDensityPlot[{-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:

StreamDensityPlot[{{-1-x^2+y,1+x-y^2},{-(1+x-y^2),-1-x^2+y}},{x,-3,3},{y,-3,3},StreamPoints->30,StreamStyle->{Red,Black}]

Use named styles:

Table[StreamDensityPlot[{-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[StreamDensityPlot[{-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[StreamDensityPlot[{-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[StreamDensityPlot[{-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[StreamDensityPlot[{-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"}}]

OpenersExampleSubsection27(Spacer1)VectorColorFunction  (4)

Color the vectors according to their norm:

StreamDensityPlot[{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]):

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

Color the vectors according to their x value:

StreamDensityPlot[{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:

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

OpenersExampleSubsection28(Spacer1)VectorColorFunctionScaling  (4)

By default, scaled values are used:

StreamDensityPlot[{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:

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

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

StreamDensityPlot[{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:

StreamDensityPlot[{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}]

OpenersExampleSubsection29(Spacer1)VectorPoints  (7)

Use automatically determined vector points:

StreamDensityPlot[{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[StreamDensityPlot[{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:

StreamDensityPlot[{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:

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

Specify a list of points for showing field vectors:

StreamDensityPlot[{-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[StreamDensityPlot[{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}};

StreamDensityPlot[{-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]}]

OpenersExampleSubsection30(Spacer1)VectorScale  (8)

Use automatically determined vector scale:

StreamDensityPlot[{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[StreamDensityPlot[{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[StreamDensityPlot[{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[StreamDensityPlot[{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:

StreamDensityPlot[{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:

StreamDensityPlot[{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:

StreamDensityPlot[{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[StreamDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->len,StreamStyle->LightGray,VectorPoints->8,VectorScale->{Large, Automatic, len}],{len,{Automatic,#5&}}]

OpenersExampleSubsection31(Spacer1)VectorStyle  (7)

Set the style for the vectors:

StreamDensityPlot[{-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:

StreamDensityPlot[{{-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,LightGray},VectorPoints->8,VectorStyle->{Yellow,Blue}]

Plot the vector fields without arrowheads:

StreamDensityPlot[{-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:

StreamDensityPlot[{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:

StreamDensityPlot[{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:

StreamDensityPlot[{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:

StreamDensityPlot[{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  (16)

Visualize a vector field with the background based on the field's divergence:

f={Sin[x]^3,-Cos[y]^2};
StreamDensityPlot[Evaluate@{f,Div[f,{x,y}]},{x,-3,3},{y,-3,3},StreamScale->Large]

Visualize a vector field with the background based on the magnitude of the field's curl:

f={Sin[y],-Sin[x]-y/4};
StreamDensityPlot[Evaluate@{f,Norm[{0,0,Curl[f,{x,y}]}]},{x,-3,3},{y,-3,3},StreamScale->Large]

Show streamlines superimposed on the Hamiltonian for a 2D Hamiltonian system:

H[x_,y_]= y^2/2 + x^2( x^2-2)/4;
V[x_,y_] = Expand[{1,-1}D[H[x,y],{{y,x}}]]

StreamDensityPlot[{V[x,y],H[x,y]},{x,-2,2},{y,-2,2}]

Check how closely (RefLink[NDSolve, paclet:ref/NDSolve]) conserves the invariant:

sol = First[NDSolve[{x'[t]==y[t],y'[t]==x[t]-x[t]^3,Thread[{x[0],y[0]}==RandomReal[{-2,2},{2}]]},{x,y},{t,0,10}, InterpolationOrder->All]];
Plot[Evaluate[(H[x[t],y[t]] - H[x[0],y[0]])/.sol],{t,0,10}]

Characterize linear planar systems interactively:

Manipulate[Row[{Text["m"]==MatrixForm[m],StreamDensityPlot[Evaluate[m.{x,y}],{x,-1,1},{y,-1,1}, StreamScale->Large, StreamColorFunction->"Rainbow"
]}],{{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 demo:

splot = StreamDensityPlot[{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]

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[StreamDensityPlot[f,{x,-3,3},{y,-3,3},Axes->False,Frame->False,ColorFunction->Hue,StreamPoints->20],ImageSize->40]

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

TabView[Table[Tooltip[fieldIcon[f[[2]]],f[[1]]]->StreamDensityPlot[f[[2]],{x,-3,3},{y,-3,3},StreamScale->0.2,ColorFunction->Hue,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},StreamDensityPlot[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[{"λ = ",λ}]]]

Homoclinic loops:

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

Unfolding a double zero eigenvalue with odd symmetry:

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

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

Explore a parameterized vector field using (RefLink[Manipulate, paclet:ref/Manipulate]):

Manipulate[StreamDensityPlot[{y,λ+μ x - x^3},{x,-3,3},{y,-3,3},StreamScale->Large,PlotLabel->{λ,μ}],{λ,-1,1},{μ,-1,1}]

Vibrating membranes:

Manipulate[StreamDensityPlot[{-x^2-λ x y^2+x,-y^3-λ x^2 y+y},{x,-3,3},{y,-3,3},StreamScale->Large,PlotLabel->Row[{"λ = ",λ}]],{λ,-5,5}]

Unfolding a function and its gradient field:

Manipulate[StreamDensityPlot[Evaluate[-D[1/3(x^3+y^3)-λ1 x y-λ2 x-λ3 y,{{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 plots for animation:

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

g=Table[labeledImage[StreamDensityPlot[{y,-1+λ+Cos[x]},{x,-3,3},{y,-3,3},StreamScale->Large],λ],{λ,-5,5,5/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[StreamDensityPlot[{-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 the field icons to switch field plots:

Manipulate[StreamDensityPlot[field,{x,-3,3},{y,-3,3},StreamStyle->style,StreamScale->scale,ColorFunction->color,ImageSize->300],{style,styles},{{color,"SandyTerrain"},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},StreamDensityPlot[{y,-1+λ+Cos[x]},{x,-3,3},{y,-3,3},StreamPoints->16,StreamScale->0.07,StreamStyle->ColorData["DeepSeaColors"][0.3i[[1]]]]],values]

Stack 2D stream plots in 3D:

make3D[GraphicsComplex[pts_,rr___],h_]:=GraphicsComplex[PadRight[pts,{Length@pts,3},h],rr]

make3D[Arrow[pts_,rr___],h_]:=Arrow[PadRight[pts,{Length@pts,3},h],rr]

stackPlots[plots2D:{__Graphics},dh_,o:OptionsPattern[Graphics3D]]:=Graphics3D[MapIndexed[Function[{g,index},g[[1]]/.p:_GraphicsComplex|_Arrow:>make3D[p,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  (9)

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

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

ListStreamDensityPlot[data]

Use (RefLink[StreamPlot, paclet:ref/StreamPlot]) for plotting only streamlines without a plot of the scalar field:

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

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

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

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

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

ListVectorDensityPlot[data]

Use (RefLink[VectorPlot, paclet:ref/VectorPlot]) to plot with vectors instead of streamlines without a plot of the scalar field:

VectorPlot[{-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}]

(RefLink[StreamDensityPlot, paclet:ref/StreamDensityPlot]) samples more points where it needs to:

StreamDensityPlot[{y,-x^2},{x,-3,3},{y,-3,3},Mesh->All]

Scalar fields can be plotted by themselves with (RefLink[DensityPlot, paclet:ref/DensityPlot]):

f={-1-x^2+y,1+x-y^2};
s=Exp[Norm[f]/10];

{DensityPlot[s,{x,-3,3},{y,-3,3},ColorFunction->"Pastel"],
StreamDensityPlot[{f,s},{x,-3,3},{y,-3,3},ColorFunction->"Pastel"]}

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}]

OpenersExampleSection5(Spacer1)Neat Examples  (3)

Plot streamlines with the divergence as the background density:

div[{vx_,vy_}] := D[vx,x]+D[vy,y]

vf = {Cos[x+y^3],Sin[y+x^3]};
StreamDensityPlot[Evaluate[{vf,div[vf]}],{x,-3,3},{y,-3,3},StreamPoints->Fine,StreamScale->Large,ColorFunction->"Rainbow",MaxRecursion->2,LightingAngle->Automatic,StreamStyle->Black]

vf = { 1,Sin[(x^3)+(y^3)]};StreamDensityPlot[Evaluate[{vf,div[vf]}],{x,-3,3},{y,-3,3},StreamPoints->Fine,StreamScale->Large,ColorFunction->"Rainbow",MaxRecursion->2,LightingAngle->Automatic,StreamStyle->Black]

vf = {Sin[Cos[3 y]+Sin[3 x]],3 Cos[Cos[3 y]+3 x]};StreamDensityPlot[Evaluate[{vf,div[vf]}],{x,-3,3},{y,-3,3},StreamScale->Large,ColorFunction->"Rainbow",MaxRecursion->2,LightingAngle->Automatic,StreamStyle->Black]

Plot streamlines with the absolute value of the vorticity as the background density:

rot[{vx_,vy_}] := Abs[D[vy,x]-D[vx,y]]

vf = {Cos[x+y^3],Sin[y+x^3]};
StreamDensityPlot[Evaluate[{vf,rot[vf]}],{x,-2,2},{y,-2,2},StreamPoints->Fine,ColorFunction->"Rainbow",MaxRecursion->2,LightingAngle->Automatic,StreamStyle->Black,StreamScale->Large]

vf = { 1,Sin[(x^3)+(y^3)]};StreamDensityPlot[Evaluate[{vf,rot[vf]}],{x,-3,3},{y,-3,3},ColorFunction->"Rainbow",MaxRecursion->3,LightingAngle->Automatic,StreamStyle->Black,StreamPoints->Fine]

vf = {Sin[Cos[3 y]+Sin[3 x]],3 Cos[Cos[3 y]+3 x]};
StreamDensityPlot[Evaluate[{vf,rot[vf]}],{x,-3,3},{y,-3,3},StreamPoints->Fine,ColorFunction->"Rainbow",MaxRecursion->2,LightingAngle->Automatic,StreamStyle->Black,StreamScale->Large]

Constrain the stream plot to a variety of regions:

StreamDensityPlot[{y,-x},{x,-2,2},{y,-2,2},RegionFunction->Function[{x,y},0.55<x^2+y^2<4.2],ColorFunction->"RedBlueTones",Frame->False,LightingAngle->Automatic,StreamScale->Medium,BoundaryStyle->{Black,Thick}]

StreamDensityPlot[{Cos[x^2+y],1+x-y^2},{x,-3,3},{y,-3,3},ColorFunction->"BeachColors",StreamColorFunction->"DeepSeaColors",StreamStyle->Black,StreamScale->{Automatic,Automatic,Scaled[0.8]},Frame->False,LightingAngle->Automatic,RegionFunction->Function[(#1+3)≥0.45 #2^2],BoundaryStyle->{Blue,Thick}]

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

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Vector Visualization, paclet:guide/VectorVisualization])}, {▪(RefLinkPlain[Function Visualization, paclet:guide/FunctionVisualization])}})}})