3
$\begingroup$

I need to visualize a few planes/slices of a 3D vector field. The first plot with only one slice is fine. Now I want to plot three slices of vectors together. And I need to separate the three planes with enough empty space in order to put something else in between. To this end, I use BoxRatios -> {1, 1, 4} below. But it strongly distorts the vectors.

Is there any way to keep a 'normal' looking of the vectors? If any wildly different method, e.g., without using BoxRatios, it's surely as well welcome.

d = {-y, x, 0}; dp0 = 0.1; dp = -{0, 0, 0.06}; vec = 2 (dp0 z - d . dp) d + (z^2 - dp0^2 + dp . dp - d . d) (-dp); vec = vec/Norm[vec]; xymax = 0.5; zlst = 0.16 {1, 0, -1}; dz = 0.05; SliceVectorPlot3D[vec, z == zlst[[1]], {x, -xymax, xymax}, {y, -xymax, xymax}, {z, zlst[[1]] + 3 dz, zlst[[1]] - 3 dz}, VectorColorFunction -> {"Rainbow", #6 &}, PlotStyle -> LightGray, BoxRatios -> Automatic, ImageSize -> Medium] SliceVectorPlot3D[vec, Table[z == zlst[[i]], {i, 3}], {x, -xymax, xymax}, {y, -xymax, xymax}, {z, zlst[[1]] + dz, zlst[[3]] - dz}, VectorColorFunction -> {"Rainbow", #6 &}, PlotStyle -> LightGray, BoxRatios -> {1, 1, 4}, ImageSize -> Large] 

enter image description here enter image description here

$\endgroup$
5
  • $\begingroup$ If you simply remove the option BoxRatios -> {1, 1, 4}, it gives this. Isn't this what you want ? $\endgroup$ Commented Jun 10, 2022 at 15:58
  • $\begingroup$ No. As I said, I need space between the planes. $\endgroup$ Commented Jun 10, 2022 at 23:42
  • $\begingroup$ a side note : the code of the OP works only once on my machine. I don't know why. If it's general for everybody, it would be good that the OP is aware of that, because it could be (one of) the reasons of a lack of answers. $\endgroup$ Commented Jun 11, 2022 at 11:27
  • $\begingroup$ @andre314 Really?? I don't spot anything suspicious in the code and it seems to plot well. $\endgroup$ Commented Jun 11, 2022 at 11:31
  • $\begingroup$ Related: mathematica.stackexchange.com/questions/215373/… $\endgroup$ Commented Jun 11, 2022 at 15:09

1 Answer 1

6
$\begingroup$

Here's one way:

SliceVectorPlot3D[ vec, Table[z == zlst[[i]], {i, 3}], {x, -xymax, xymax}, {y, -xymax, xymax}, {z, zlst[[1]] + dz, zlst[[3]] - dz}, VectorColorFunction -> {"Rainbow", #6 &}, PlotStyle -> LightGray, BoxRatios -> {1, 1, 4}, ImageSize -> Large ] /. a_Arrow :> Scale[a, {1, 1, 1/4}] 

enter image description here

This works by simply applying Scale to each of the arrows to rescale their vertical dimension to 1/4, to compensate for the scaling done by BoxRatios.

$\endgroup$
1
  • $\begingroup$ Nice answer, thank you! $\endgroup$ Commented Jun 13, 2022 at 2:31

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.