({{, (RefLink[VectorPlot3D, paclet:ref/VectorPlot3D])[{(Subscript[v, x]),(Subscript[v, y]),(Subscript[v, z])},{x,(Subscript[x, min]),(Subscript[x, max])},{y,(Subscript[y, min]),(Subscript[y, max])},{z,(Subscript[z, min]),(Subscript[z, max])}] 
generates a 3D vector plot of the vector field {(Subscript[v, x]),(Subscript[v, y]),(Subscript[v, z])} as a function of x, y, and z.}, {, (RefLink[VectorPlot3D, paclet:ref/VectorPlot3D])[{(Subscript[field, 1]),(Subscript[field, 2]),…},{x,(Subscript[x, min]),(Subscript[x, max])},{y,(Subscript[y, min]),(Subscript[y, max])},{z,(Subscript[z, min]),(Subscript[z, max])}]
plots several vector fields.}})

OpenersNotesSection(Spacer1)Details and Options

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

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

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

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

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

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

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

OpenersPrimaryExamplesSection(Spacer1)Examples  (76)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Plot a vector field:

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

OpenersExampleSection1(Spacer1)Scope  (13)

OpenersExampleSubsection0(Spacer1)Sampling  (5)

Plot multiple vector fields:

VectorPlot3D[{{y,-x,z},{x,y,z}},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->All, VectorPoints->5]

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

VectorPlot3D[Evaluate[D[Sin[x y z],{{x,y,z}}]],{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->All, VectorPoints->5]

Plot vectors over specified regions:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},RegionFunction->((#1 #2 #3>0)&)]

Plot a vector field with vectors placed with specified densities:

Table[VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotLabel->k,VectorPoints->k],{k,{Fine,Automatic,5,{4,6,8}}}]

Plot a field with arrows placed at random locations:

points = RandomReal[{-1,1},{500,3}];

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->points]

OpenersExampleSubsection1(Spacer1)Presentation  (8)

Plot a vector field with arrows colored by the (RefLink[Norm, paclet:ref/Norm]) of the field:

VectorPlot3D[{y,-x,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->All,VectorPoints->5,VectorColorFunction->Hue]

Plot with 3D arrows:

VectorPlot3D[{y,-x,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->All, VectorPoints->5,VectorStyle->"Arrow3D",VectorColorFunction->"Rainbow"]

Plot a field with arbitrary three-dimensional shapes:

g={Graphics3D[Cylinder[{{0,0,0},{1,0,0}},0.5]],Graphics3D[Cone[{{-0.5,0,0},{1.5,0,0}},0.5]]}

VectorPlot3D[{y,-x,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorColorFunction->Hue,VectorPoints->4,VectorStyle->{g},VectorScale->{Automatic,Scaled[0.3]}]

Color and scale the vectors based on the norm of the field:

points = RandomReal[{-1,1},{500,3}];

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->points,PlotRange->All,VectorScale->{Automatic,Scaled[0.5]},VectorColorFunction->Hue]

Plot a vector field with arrows of specified size:

Table[VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->5,VectorScale->s,PlotLabel->s],{s,{Small,Large,0.15,Automatic}}]

Vary the arrow length and arrowhead size:

Table[VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->6,VectorScale->s,PlotLabel->s],{s,{{Large,1},{Large,Scaled[0.5]},{Large,Automatic,#1&}}}]

Include a legend:

points = Normalize/@RandomReal[{-1,1},{250,3}];

VectorPlot3D[{{x,y,z},{z,-y,x+y}},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->points,VectorScale->0.15,PlotLegends->{"one","two"}]

Use a highly stylized theme:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotTheme->"Marketing"]

OpenersExampleSection2(Spacer1)Options  (57)

OpenersExampleSubsection2(Spacer1)BoxRatios  (2)

By default, (RefLink[BoxRatios, paclet:ref/BoxRatios]) is set to (RefLink[Automatic, paclet:ref/Automatic]):

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},BoxRatios->Automatic]

Make the height appear twice the width and length:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},BoxRatios->{1,1,2}]

OpenersExampleSubsection3(Spacer1)EvaluationMonitor  (2)

Show where the function is sampled:

ListPointPlot3D[Reap[VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},EvaluationMonitor:>Sow[{x,y,z}]]][[-1,1]]]

Count how many times the vector field function is evaluated:

Block[{k=0},VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},EvaluationMonitor:>k++];k]

OpenersExampleSubsection4(Spacer1)PerformanceGoal  (2)

Generate a higher-quality plot:

VectorPlot3D[{y,-x,z},{x,-1,1},{y,-1,1},{z,-1,1},PerformanceGoal->"Quality"]

Emphasize performance, possibly at the cost of quality:

VectorPlot3D[{y,-x,z},{x,-1,1},{y,-1,1},{z,-1,1},PerformanceGoal->"Speed"]

OpenersExampleSubsection5(Spacer1)PlotLegends  (3)

No legends are included by default:

VectorPlot3D[{{x,y,z},{z,-y,x+y}},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->10]

Include a legend:

VectorPlot3D[{{x,y,z},{z,-y,x+y}},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->10,PlotLegends->{"one","two"}]

Control the placement of the legend:

VectorPlot3D[{{x,y,z},{z,-y,x+y}},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->10,PlotLegends->Placed[{"one","two"},Below]]

OpenersExampleSubsection6(Spacer1)PlotRange  (10)

The full plot range is used by default:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->Full]

Use all points to compute the range:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->All]

Specify an explicit limit for x, y, and z ranges:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->2]

Specify an explicit range that applies to all x, y, and z ranges:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->{-1.5,2.}]

Specify an explicit x range:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->{{-1,2}}]

Specify an explicit x minimum range:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->{{0,Full}}]

Specify an explicit y range:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->{Full,{0,2}}]

Specify an explicit y maximum range:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->{Full,{Full,3}}]

Specify an explicit z range:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->{Full,Full,{-2,2}}]

Specify different x, y, and z ranges:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRange->{{-2,1.5},{-1,2},{0,1}}]

OpenersExampleSubsection7(Spacer1)PlotRangePadding  (8)

Padding is computed automatically by default:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRangePadding->Automatic]

Specify no padding for all x, y, and z ranges:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRangePadding->None]

Specify an explicit padding for all x, y, and z ranges:

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

Add 10% padding to all x, y, and z ranges:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRangePadding->Scaled[0.1]]

Specify padding for x and y ranges:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRangePadding->{1,0.5}]

Specify different padding for x, y, and z ranges:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRangePadding->{1,0.5,2}]

Specify padding for the z range:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRangePadding->{Automatic,Automatic,2}]

Use different padding forms for each dimension:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotRangePadding->{Automatic,Scaled[0.05],2}]

OpenersExampleSubsection8(Spacer1)PlotTheme  (2)

Use a theme with dense vector points and legends:

VectorPlot3D[{{x,y,z},{z,-y,x+y}},{x,0,1},{y,0,1},{z,0,1},PlotTheme->"Detailed"]

Reduce the number of vector points:

VectorPlot3D[{{x,y,z},{z,-y,x+y}},{x,0,1},{y,0,1},{z,0,1},PlotTheme->"Detailed",VectorPoints->Coarse]

OpenersExampleSubsection9(Spacer1)RegionFunction  (3)

Plot vectors only over certain quadrants:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},RegionFunction->((#1 #2 #3>0)&)]

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

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},RegionFunction->((#7>1.4)&)]

Use any logical combination of conditions:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},RegionFunction->((0.3<#7<0.5||1.5<#7<2)&)]

OpenersExampleSubsection10(Spacer1)VectorColorFunction  (4)

Color the vectors according to their norm:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorColorFunction->Hue]

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

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorColorFunction->"Rainbow"]

Color the vectors according to their x value:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorColorFunction->Function[{x,y,z,vx,vy,vz,n},ColorData["ThermometerColors"][x]]]

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

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorColorFunction->(ColorData[22][Round[#7]]&),VectorColorFunctionScaling->False]

OpenersExampleSubsection11(Spacer1)VectorColorFunctionScaling  (4)

By default, scaled values are used:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorColorFunction->Hue]

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

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorColorFunction->(ColorData[22][Round[#7]]&),VectorColorFunctionScaling->False]

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

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorColorFunction->Function[{x,y,z,vx,vy,vz,n},Hue[x,y,1]], VectorColorFunctionScaling->{False,True}]

Explicitly specify the scaling for each color function argument:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorColorFunction->(Hue[#7,#2,1]&), VectorColorFunctionScaling->{True,True,True,True,False}]

OpenersExampleSubsection12(Spacer1)VectorPoints  (7)

Use automatically determined vector points:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->Automatic]

Use symbolic names to specify the set of field vectors:

Table[VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotLabel->k,VectorPoints->k],{k,{Fine,Coarse}}]

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

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->5]

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

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1}, VectorPoints->{4,7,9}]

Specify a list of points for showing field vectors:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->RandomReal[{-1,1},{300,3}],VectorScale->Large]

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

Table[VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotLabel->n,VectorPoints->n,VectorScale->Medium],{n,4,10,3}]

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

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

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->points,VectorScale->.25]

OpenersExampleSubsection13(Spacer1)VectorScale  (7)

Use automatically determined vector scale:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorScale->Automatic]

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

Table[VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->4,PlotLabel->s,VectorScale->s],{s,{0.1,0.2}}]

Use symbolic names to control the size of vectors:

Table[VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},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[VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotLabel->ToString[f],VectorScale->{Automatic,Automatic,f}],{f,{None,Automatic}}]

Specify an absolute size for the arrowheads:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->4,VectorScale->{Large,1}]

Specify arrowhead size relative to the length of the arrow:

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->4,VectorScale->{Large,Scaled[0.5]}]

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

VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorScale->{Large,Automatic,#1&}]

OpenersExampleSubsection14(Spacer1)VectorStyle  (3)

Plot a vector field using 3D arrows:

Table[VectorPlot3D[{x,y,z},{x,-1,1},{y,-1,1},{z,-1,1},PlotLabel->s,VectorStyle->s],{s,{"Arrow3D","Segment"}}]

Use (RefLink[Graphics3D, paclet:ref/Graphics3D]) as a style for the 3D arrows:

g={Graphics3D[Cylinder[{{0,0,0},{1,0,0}},0.5]],Graphics3D[Cone[{{-0.5,0,0},{1.5,0,0}},0.5]]}

VectorPlot3D[{y,-x,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorColorFunction->Hue,VectorPoints->4,VectorStyle->{g},VectorScale->{Automatic,Scaled[0.3]}]

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

VectorPlot3D[{x,-y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->5,VectorStyle->Arrowheads[{{0.02,1,Graphics3D[Sphere[]]}}]]

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

VectorPlot3D[{x,-y,z},{x,-1,1},{y,-1,1},{z,-1,1},VectorPoints->5,VectorScale->{Automatic,Scaled[0.4]},VectorStyle->Graphics3D[Sphere[{0,0,0},0.3]]]

OpenersExampleSection3(Spacer1)Applications  (3)

Use a contour plot to visualize the region of a vector plot:

scalarField=x^2-y^2-z;

vectorField=D[scalarField,{{x,y,z}}]

Plot a vector field over a particular region:

v=VectorPlot3D[vectorField,{x,-2,2},{y,-2,2},{z,-2,2},VectorPoints->25,VectorScale->{0.1,Scaled[0.5]},RegionFunction->Function[{x,y,z},-0.1≤scalarField<=0.1]]

Create a contour plot of the vector plot's region:

c=ContourPlot3D[scalarField==0,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,ContourStyle->Opacity[0.5,Green]]

Combine the vector and contour plots:

Show[v,c]

Plot the vector field in a spherical region:

g=VectorPlot3D[{Sin[x],Sin[y]^2,Cos[z]^3-Sin[x]},{x,-6,6},{y,-6,6},{z,-6,6},VectorStyle->"Arrow3D",VectorPoints->25,VectorColorFunction->"TemperatureMap",VectorScale->{0.1,Scaled[0.5]},RegionFunction->Function[{x,y,z},4^2<x^2+y^2+z^2<5^2]]

Add an inner sphere:

Show[g,Graphics3D[Sphere[{0,0,0},4]]]

An electrostatic potential built from a collection of point charges (Subscript[q, i]) at positions (Subscript[p, i]):

electroStaticPotential[q_,p_,r_] :=Sum[ ((q[[i]])/(Norm[r-p[[i]]])), {i,Length[q]}]

electroStaticPotential[{(Subscript[q, 1]),(Subscript[q, 2])},{{(Subscript[x, 1]),(Subscript[y, 1]),(Subscript[z, 1])},{(Subscript[x, 2]),(Subscript[y, 2]),(Subscript[z, 2])}},{x,y,z}]//TraditionalForm

An electric field between two charges (Subscript[q, 1]) and (Subscript[q, 2]):

electricField[{q1_,q2_},{{x1_,y1_,z1_},{x2_,y2_,z2_}}]=-D[electroStaticPotential[{q1,q2},{{x1,y1,z1},{x2,y2,z2}},{x,y,z}],{{x,y,z}}]/.Abs'[x_]:>(x/(Sqrt[(x^2)]));

The electrostatic potential between two charges (Subscript[q, 1])==1 and (Subscript[q, 2])==-1:

c=ContourPlot3D[Evaluate[electroStaticPotential[{1,-1},{{-1,0,0},{1,0,0}},{x,y,z}]],{x,-6,6},{y,0,4},{z,-4,4},Contours->{-0.75,-0.25,-0.1,0,0.1,0.25,0.75},  ContourStyle->Table[Hue[i/7,1,1,0.5],{i,0,6}],Mesh->None]

The electric field between two charges (Subscript[q, 1])==1 and (Subscript[q, 2])==-1:

v=VectorPlot3D[electricField[{1,-1},{{-1,0,0},{1,0,0}}],{x,-6,6},{y,0,4},{z,-4,4},VectorStyle->"Arrow3D",VectorPoints->5,VectorScale->{.3,Scaled[0.3]}]

Combine both visualizations:

Show[c,v]

OpenersExampleSection4(Spacer1)Properties & Relations  (2)

Use (RefLink[ListVectorPlot3D, paclet:ref/ListVectorPlot3D]) to visualize data:

vectors = Table[{x,y,z},{x,-1,1,.1},{y,-1,1,.1},{z,-1,1,.1}];

ListVectorPlot3D[vectors]

Visualizing 2D vector field functions:

Table[f[{-1-x^2+y,1+x-y^2},{x,-3,3},{y,-3,3},PlotLabel->f],{f,{VectorPlot,VectorDensityPlot,StreamPlot,StreamDensityPlot,LineIntegralConvolutionPlot}}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[SliceVectorPlot3D, paclet:ref/SliceVectorPlot3D])  ▪  (RefLink[ListVectorPlot3D, paclet:ref/ListVectorPlot3D])  ▪  (RefLink[VectorPlot, paclet:ref/VectorPlot])  ▪  (RefLink[StreamPlot, paclet:ref/StreamPlot])  ▪  (RefLink[ContourPlot3D, paclet:ref/ContourPlot3D])}})}})

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