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

OpenersNotesSection(Spacer1)Details and Options

(RefLink[VectorDensityPlot, paclet:ref/VectorDensityPlot]) by default shows vectors from the vector field at a regular grid of positions.

(RefLink[VectorDensityPlot, paclet:ref/VectorDensityPlot]) omits any vectors for which the (Subscript[v, i]) etc. do not evaluate to real numbers.

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

(RefLink[VectorDensityPlot, paclet:ref/VectorDensityPlot]) 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[VectorDensityPlot, paclet:ref/VectorDensityPlot]) 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[VectorColorFunction, paclet:ref/VectorColorFunction]) 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  (157)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Plot the vector field {y,-x} with background color based on the field magnitude:

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

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

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

Plot two vector fields with background color based on the function x+y:

VectorDensityPlot[{{y,-x},{x,y},x+y},{x,-3,3},{y,-3,3}]

Use a plot theme with minimal styling:

VectorDensityPlot[{{y,-x},{x,y},x+y},{x,-3,3},{y,-3,3},PlotTheme->"Minimal"]

OpenersExampleSection1(Spacer1)Scope  (22)

OpenersExampleSubsection0(Spacer1)Sampling  (10)

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

VectorDensityPlot[{{y,-x},Cos[x]},{x,-3,3},{y,-3,3},VectorPoints->8]

Plot multiple vector fields:

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

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

Plot a vector field with vectors placed with specified densities:

Table[VectorDensityPlot[{y,-x},{x,-2,2},{y,-2,2},PlotLabel->k,VectorPoints->k],{k,{5,Coarse,Automatic,Fine}}]

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

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

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

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

VectorDensityPlot[{y,-x},{x,-3,3},{y,-3,3}, VectorPoints->{4,7}]

Specify a list of points for showing field vectors:

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

Plot vectors over a specified region:

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

The domain may be specified by a region:

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

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

OpenersExampleSubsection1(Spacer1)Presentation  (12)

Plot a vector field with constant size arrows:

VectorDensityPlot[{y,-x},{x,-3,3},{y,-3,3},VectorScale->{Automatic,Automatic,None}]

Plot a vector field with arrows of specified size:

Table[VectorDensityPlot[{x,-y},{x,-3,3},{y,-3,3},VectorColorFunction->Hue,PlotLabel->s,VectorScale->s], {s,{Small,Medium,Large,0.15}}]

Specify the arrow length and arrowhead size:

Table[VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->s,VectorScale->s],{s,{{Large,1},{Large,Scaled[1]},{Large,Automatic,#1&}}}]

Plot a vector field with the background and vectors colored according to the field magnitude:

VectorDensityPlot[{y,-x},{x,-3,3},{y,-3,3},ColorFunction->"Pastel",VectorColorFunction->Hue]

Set the style for multiple vector fields:

VectorDensityPlot[{{-1-x^2+y,1+x-y^2},{-(1+x-y^2),-1-x^2+y}},{x,-3,3},{y,-3,3},VectorPoints->8,VectorStyle->{{Red,"Drop"},{Blue,"Dart"}}]

Apply vector style:

VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},VectorPoints->8,VectorStyle->Arrowheads[{{0.03,Automatic,Graphics[Circle[]]}}]]

Use a named appearance to draw the vectors:

VectorDensityPlot[{y,-x},{x,-3,3},{y,-3,3},VectorMarkers->"Drop"]

Style the vectors as well:

VectorDensityPlot[{y,-x},{x,-3,3},{y,-3,3},VectorMarkers->"Drop",VectorStyle->Red]

Plot vectors and streamlines together:

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

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

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

VectorDensityPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotLegends->LineLegend[1,{"one","two"}]]

Include a legend for the scalar field:

VectorDensityPlot[{{x,y},{y,-x}},{x,-3,3},{y,-3,3},PlotLegends->BarLegend[{Automatic,{0,Norm[{3,3}]}}]]

OpenersExampleSection2(Spacer1)Options  (120)

OpenersExampleSubsection2(Spacer1)AspectRatio  (2)

By default, the aspect ratio is 1:

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

Set the aspect ratio:

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

VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},VectorStyle->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<9||0<n<2];

VectorDensityPlot[{-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<9||0<n<2];

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

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

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

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

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

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

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

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

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

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

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

VectorDensityPlot[{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[VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},EvaluationMonitor:>Sow[{x,y}]]][[-1,1]],AspectRatio->1]

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

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

OpenersExampleSubsection8(Spacer1)FrameLabel  (1)

Label the axes:

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

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

Show the initial and final sampling meshes:

Table[VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->m,Mesh->m],{m,{Full,All}}]

Use a specific number of mesh lines:

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

Specify mesh lines:

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

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

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

Use the x value as the mesh function:

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

Use mesh lines corresponding to fixed distances from the origin:

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

OpenersExampleSubsection13(Spacer1)MeshShading  (3)

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

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

Styles are used cyclically:

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

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

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

Randomly vary the effective normals:

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

OpenersExampleSubsection16(Spacer1)PerformanceGoal  (2)

Generate a higher-quality plot:

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

Emphasize performance, possibly at the cost of quality:

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

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

Include a legend for the streamlines:

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

Include a legend for the scalar field:

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

Control the placement of the legend:

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

OpenersExampleSubsection18(Spacer1)PlotRange  (8)

The full plot range is used by default:

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

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

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

Specify an explicit x range:

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

Specify an explicit x minimum range:

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

Specify an explicit y range:

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

Specify an explicit y maximum range:

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

Specify different x and y ranges:

VectorDensityPlot[{-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 theme with simple ticks and grid lines in a high contrast color scheme:

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

Change the color scheme:

VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},RegionFunction->Function[{x,y,vx,vy,n},x y<0],PlotTheme->"Marketing",ColorFunction->"TemperatureMap"]

OpenersExampleSubsection20(Spacer1)RegionFunction  (4)

Plot vectors only over certain quadrants:

VectorDensityPlot[{-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 vectors only over regions where the field magnitude is above a given threshold:

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

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

OpenersExampleSubsection21(Spacer1)StreamColorFunction  (5)

Color streamlines according to the norm of the vector field:

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

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

VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamPoints->Coarse,StreamColorFunction->"ValentineTones"]

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

VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamPoints->Coarse,StreamColorFunction->Function[{x,y,vx,vy,n},ColorData["SolarColors"][x y]]]

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

VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamPoints->Coarse,StreamColorFunction->Function[{x,y,vx,vy,n},Blend[{Yellow,Red},x]]]

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

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

OpenersExampleSubsection22(Spacer1)StreamColorFunctionScaling  (4)

By default, scaled values are used:

VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamPoints->Coarse,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:

VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},StreamPoints->Coarse,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:

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

Explicitly specify the scaling for each color function argument:

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

OpenersExampleSubsection23(Spacer1)StreamPoints  (6)

Specify a specific maximum number of streamlines:

VectorDensityPlot[{-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[VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},VectorStyle->Orange,StreamPoints->p,PlotLabel->p],{p,{Automatic,Coarse,Fine}}]

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

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

Specify the minimum distance between streamlines:

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

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

Table[VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->d,VectorStyle->Orange,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[VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},VectorStyle->Orange,StreamPoints->{points,Automatic,maxlen},Epilog->Point[points]],{maxlen,{2.5,Scaled[0.2]}}]

OpenersExampleSubsection24(Spacer1)StreamScale  (9)

Create full streamlines without segmentation:

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

Use curves for streamlines:

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

Use symbolic names to control the lengths of streamlines:

Table[VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->s,VectorStyle->Orange,StreamPoints->Coarse,StreamScale->s],{s,{Tiny,Large}}]

Specify segment lengths:

Table[VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->s,VectorStyle->Orange,StreamPoints->Coarse,StreamScale->s],{s,{0.1,0.2,0.4}}]

Specify an explicit dashing pattern for streamlines:

VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},VectorStyle->Orange,StreamPoints->Coarse,StreamScale->{{0.1,0.1},Automatic}]

Specify the number of points rendered on each streamline segment:

Table[VectorDensityPlot[{y,-x},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->n,VectorStyle->Orange,StreamPoints->Coarse,StreamScale->{Full,n}],{n,{10,15,All}}]

Specify absolute aspect ratios relative to the longest line segment:

Table[VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},VectorStyle->Orange,StreamPoints->Coarse,PlotLabel->a,StreamScale->{Automatic,Automatic,a}],{a,{.02,.04}}]

Specify relative aspect ratios relative to each line segment:

Table[VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},VectorStyle->Orange,StreamPoints->Coarse,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:

VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},VectorScale->Tiny,VectorStyle->Orange,StreamPoints->Coarse,StreamScale->{Automatic,2,Automatic,Function[{x,y,vx,vy,n},Scaled[y]]}]

OpenersExampleSubsection25(Spacer1)StreamStyle  (8)

Apply a variety of styles to the streamlines:

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

Specify a custom arrowhead:

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

Set the style for multiple vector fields:

VectorDensityPlot[{{-1-x^2+y,1+x-y^2},{-(1+x-y^2),-1-x^2+y}},{x,-3,3},{y,-3,3},StreamPoints->20,StreamStyle->{Red,LightGray}]

Use named styles:

VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->#,StreamPoints->Coarse,StreamScale->{Full,All,0.05},StreamStyle->#]&/@{"Segment","Line"}

Named arrow styles:

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

Named dot styles:

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

Named pointer styles:

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

Named dart styles:

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

OpenersExampleSubsection26(Spacer1)VectorColorFunction  (4)

Color the vectors according to their norm:

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorScale->Large,VectorColorFunction->Hue]

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

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorScale->Large,VectorColorFunction->"Rainbow"]

Color the vectors according to their x values:

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorScale->Large,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:

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorScale->Large,VectorColorFunction->Function[{x,y,vx,vy,n},ColorData[22][Round[n]]],VectorColorFunctionScaling->False]

OpenersExampleSubsection27(Spacer1)VectorColorFunctionScaling  (4)

By default, scaled values are used:

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorScale->Large,VectorColorFunction->Hue]

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

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorScale->Large,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:

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorScale->Large,VectorColorFunction->Function[{x,y,vx,vy,n},Hue[x,y,1]], VectorColorFunctionScaling->{False,True}]

Explicitly specify the scaling for each color function argument:

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorScale->Large,VectorColorFunction->Function[{x,y,vx,vy,n},Hue[n,y,1]], VectorColorFunctionScaling->{True,True,True,True,False}]

OpenersExampleSubsection28(Spacer1)VectorMarkers  (4)

Vectors are drawn as arrows by default:

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

Use a named appearance to draw the vectors:

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorMarkers->"Drop"]

Use different markers for different vector fields:

VectorDensityPlot[{{y,-x },{x,y}},{x,-3,3},{y,-3,3},VectorMarkers->{"Drop","Dart"}]

By default, markers are centered on vector points:

pts=Tuples[Range[-3,3],2];

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorMarkers->"Arrow",VectorPoints->pts,Epilog->{Red,Point[pts]}]

Start the vectors at the points:

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorMarkers->Placed["Arrow","Start"],VectorPoints->pts,Epilog->{Red,Point[pts]}]

End the vectors at the points:

VectorDensityPlot[{y,-x },{x,-3,3},{y,-3,3},VectorMarkers->Placed["Arrow","End"],VectorPoints->pts,Epilog->{Red,Point[pts]}]

OpenersExampleSubsection29(Spacer1)VectorPoints  (7)

Use automatically determined vector points:

VectorDensityPlot[{y,-x},{x,-2,2},{y,-2,2},VectorPoints->Automatic]

Use symbolic names to specify the set of field vectors:

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

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

VectorDensityPlot[{y,-x},{x,-3,3},{y,-3,3},VectorPoints->5]

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

VectorDensityPlot[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3}, VectorPoints->{4,7}]

Specify a list of points for showing field vectors:

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

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

Table[VectorDensityPlot[{y^2,x^2-y^2},{x,-3,3},{y,-3,3},PlotLabel->n,VectorPoints->n,VectorScale->Medium,MaxRecursion->3],{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}};

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

OpenersExampleSubsection30(Spacer1)VectorScale  (8)

Use automatically determined vector scale:

VectorDensityPlot[{y,-x},{x,-3,3},{y,-3,3},VectorScale->Automatic]

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

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

Use symbolic names to control the size of vectors:

Table[VectorDensityPlot[{y,-x},{x,-3,3},{y,-3,3},VectorScale->s,PlotLabel->s],{s,{Tiny,Small,Medium,Large}}]

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

Table[VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->ToString[f],VectorScale->{Automatic,Automatic,f}],{f,{None,Automatic}}]

Specify an absolute size for the arrowheads:

VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},VectorScale->{Large,1}]

Specify arrowhead size relative to the length of the arrow:

VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},VectorScale->{Large,Scaled[1]}]

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

VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},VectorScale->{Large,Automatic,#1&}]

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

Table[VectorDensityPlot[{Sin[x],Cos[y]},{x,-Pi,Pi},{y,-Pi,Pi},PlotLabel->len,VectorScale->{Large, Automatic, len}],{len,{Automatic,#5&}}]

OpenersExampleSubsection31(Spacer1)VectorStyle  (7)

Set the style for the displayed vectors:

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

Set the style for multiple vector fields:

VectorDensityPlot[{{-1-x^2+y,1+x-y^2},{-(1+x-y^2),-1-x^2+y}},{x,-3,3},{y,-3,3},VectorPoints->8,VectorStyle->{Red,Blue}]

Plot the vector fields without arrowheads:

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

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

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

Specify both arrow tail and head:

VectorDensityPlot[{x,y},{x,-1,1},{y,-1,1},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:

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

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

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

OpenersExampleSection3(Spacer1)Applications  (3)

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

f={Sin[x]^3,-Cos[y]^2};
VectorDensityPlot[Evaluate@{f,D[f[[1]],x]+D[f[[2]],y]},{x,-3,3},{y,-3,3},VectorPoints->12]

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

f={Sin[y],-Sin[x]-y/4};
VectorDensityPlot[Evaluate@{f,Norm[{0,0,D[f[[2]],x]-D[f[[1]],y]}]},{x,-3,3},{y,-3,3},VectorPoints->12]

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[VectorDensityPlot[f,{x,-3,3},{y,-3,3},Axes->False,Frame->False,StreamPoints->20,StreamStyle->"Line",ColorFunction->"SandyTerrain"],ImageSize->42],{f,fields}];

Click on the field icons to switch field plots:

Manipulate[VectorDensityPlot[field,{x,-3,3},{y,-3,3},VectorStyle->style,VectorScale->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}]

OpenersExampleSection4(Spacer1)Properties & Relations  (7)

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

ListVectorDensityPlot[Table[{-1-x^2+y,1+x-y^2},{x,-3,3,0.2},{y,-3,3,0.2}]]

Use (RefLink[VectorPlot, paclet:ref/VectorPlot]) to plot functions without a density plot:

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

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

ListStreamDensityPlot[Table[{-1-x^2+y,1+x-y^2},{x,-3,3,0.2},{y,-3,3,0.2}]]

Use (RefLink[ListVectorPlot, paclet:ref/ListVectorPlot]) for plotting data without a density plot:

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

ListVectorPlot[data,VectorPoints->8]

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

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

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"],
VectorDensityPlot[{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  (1)

Constrain the vector plot to a variety of regions:

VectorDensityPlot[{Cos[y]-Sin[x]^3,-.1 y-Sin[x]},{x,-4,4},{y,-4,4},Frame->False,VectorScale->{0.05,Automatic,None},VectorPoints->25,AspectRatio->Automatic,ColorFunction->"IslandColors",VectorColorFunction->"RedBlueTones",BoundaryStyle->{Red,Thick},RegionFunction->Function[#2+#1+0.3≥Sin[#1]]]

VectorDensityPlot[{Cos[x+y^3],Sin[y+x^3]},{x,-3,3},{y,-3,3},Frame->False,ColorFunction->"TemperatureMap",VectorScale->{Automatic,Automatic,Automatic},RegionFunction->Function[#1^2+#2^2≤9],BoundaryStyle->Thick,MaxRecursion->2,VectorColorFunction->"RoseColors",VectorPoints->Fine]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[VectorPlot, paclet:ref/VectorPlot])  ▪  (RefLink[StreamPlot, paclet:ref/StreamPlot])  ▪  (RefLink[ListVectorPlot, paclet:ref/ListVectorPlot])  ▪  (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])}})}})

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