# Assign a color to VectorPlot

I want to set all the lines in a VectorPlot a specific color, like Red. I am using some of the new options for VectorPlot as my code below illustrates. Using VectorColorFunction -> Red does not solve my problem.

VectorPlot[{1, t - x}, {t, -2, 2}, {x, -2, 2}, VectorPoints -> 17,
VectorScaling -> Automatic, VectorSizes -> 1.2,
VectorStyle -> Arrowheads[0], VectorColorFunction -> Red]


I think this is what you're looking for:

VectorPlot[{1, t - x}, {t, -2, 2}, {x, -2, 2}, VectorPoints -> 17,
VectorScaling -> Automatic, VectorSizes -> 1.2, VectorStyle -> Red,
VectorMarkers -> "Segment", VectorColorFunction -> None]


• VectorColorFunction -> None to not color the vectors by magnitude
• VectorStyle -> Red to set the color
• VectorMarkers -> "Segment to just get lines

(As an alternative to using VectorMarkers, you could also use VectorStyle -> Directive[Red, Arrowheads[0]].)

Replace Red with (Red &) in your code to get the desired result:

 VectorPlot[{1, t - x}, {t, -2, 2}, {x, -2, 2},
VectorPoints -> 17, VectorScaling -> Automatic, VectorSizes -> 1.2,
VectorStyle -> Arrowheads[0], VectorColorFunction -> (Red &)]



So to get a constant function that returns Red for all arguments we need to use Red& The parentheses in VectorColorFunction -> (Red &) is added because without parentheses this expression would be parsed as (VectorColorFunction -> Red) &.

The following example comes from the help of D entry:

   ClearAll["Global*"]
v[x_, y_] := {1, x - y}
curl[{x_, y_}] = D[x + y, x] - D[x^2 y, y];
Manipulate[
VectorPlot[v[x, y], {x, -2, 2}, {y, -2, 2}, ImageSize -> Medium,
Epilog -> {If[curl[s] > 0, Green, Red], Thick, Dashed, Point[s],
Circle[s, Abs[curl[s]/3]]}], {{s, {0, 0}}, {-2, -2}, {2, 2}},
SaveDefinitions -> True]


We can also specify multiple display colors by condition:

    f[x_, y_] := Evaluate[Curl[{1, x - y}, {x, y}]]
StreamPlot[{1, x - y}, {x, -2, 2}, {y, -2, 2}] /. {Arrowheads[spec_],
0.01*Abs[
f[pts[[1, 1]],
pts[[1, 2]]]]], {If[(x - y /. {x -> pts[[1, 1]],
y -> pts[[1, 2]]}) > 0, Red, Black], Arrow[pts]}}


Or

VectorPlot[{1, t - x}, {t, -2, 2}, {x, -2, 2}, VectorPoints -> 17,
VectorScaling -> False, VectorSizes -> 1.2,
VectorColorFunctionScaling ->
False(*this option must be set to false*),
`