# VectorPlot interval as a union of intervals

What would you suggest me to do if I want to use VectorPlot in a certain region of a plane? e.g.:

data1 = {{3.3, 2.97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.8,
4.2}, {3.85, 3.65, 3.76, 3.41, 3.31, 3.33, 3.35, 3.3, 3.38, 3.44,
3.6, 3.65, 4., 4.2, 4.45}, {4.48, 4.35, 4.45, 4.28, 4.22, 4.25,
4.31, 4.3, 4.32, 4.37, 4.45, 4.46, 4.6, 4.67, 4.76}, {5.08, 5.09,
5.17, 5.25, 5.23, 5.27, 5.27, 5.28, 5.3, 5.3, 5.35, 5.3, 5.27,
5.23, 5.22}, {5.75, 5.85, 5.25, 6.18, 6.31, 6.30, 6.45, 6.44,
6.65, 6.62, 6.52, 6.41, 6.17, 6.02, 5.86}, {7.5, 7.22, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 6.33, 6.22}, {6.56, 6.74, 7.01,
7.28, 7.41, 7.52, 7.52, 7.53, 7.51, 7.45, 7.36, 7.22, 6.95, 6.63,
6.5}, {6.9, 7.03, 7.08, 7.22, 7.3, 7.32, 7.35, 7.34, 7.29, 7.23,
7.18, 7.12, 7.0, 6.84, 6.7}};


Interpolating:

intF = Interpolation[Flatten[MapIndexed[{#2, #} &, Transpose@data1, {2}], 1],InterpolationOrder -> {1, 1}, Method -> "Hermite"];
cp = ContourPlot[intF[x, y], {x, 1, 15}, {y, 0.9, 8}, Contours -> Range[0.1, 12], AspectRatio -> Automatic, ImageSize -> Medium, PlotLegends -> {Automatic}];

sp = StreamPlot[Evaluate[-D[intF[x, y], {{x, y}}]], {x, 1, 15}, {y, u} , StreamScale -> Coarse, StreamStyle -> {"Arrow", Directive[Thin, Blue]}, StreamPoints -> Fine, AspectRatio -> Automatic, VectorScale -> Automatic];
vp := VectorPlot[Evaluate[-D[intF[x, y], {{x, y}}]], {x, 1, 15}, {y, 1.5, 8}, VectorScale -> Automatic, VectorStyle -> {LighterBlue}]
sp2 = MapAt[{Opacity[0.25], #} &, sp, 1];
Show[cp, vp, sp2]


In this case I want to constrain the values given to y in:

vp := VectorPlot[Evaluate[-D[intF[x, y], {{x, y}}]], {x, 1, 15}, {y, 1.5, 8}, VectorScale -> Automatic, VectorStyle -> {LighterBlue}]


Something like:

u=IntervalUnion[{1,5.9},{6.1,8}]


then:

vp := VectorPlot[Evaluate[-D[intF[x, y], {{x, y}}]], {x, 1, 15}, {y, u}, VectorScale -> Automatic, VectorStyle -> {LighterBlue}]


is this possible?

Edit: the idea is to avoid vectors in the region of the upper bar:

because those tend to modify the scale of the vectors and its magnitudes.

Edit2: I made it defining two different vector plots, say, vp and vp2, which are defined in different Regions, but anyways it still will be nice if there's another way.

• RegionFunction should do what you want, add e.g. RegionFunction -> (IntervalMemberQ[Interval[{1, 5.5}, {6.5, 8}], #2] &) as option to VectorPlot – Lukas Lang Sep 1 '19 at 19:43