1
$\begingroup$

I'm trying to plot the following VectorField:

VectorPlot[{x/Sqrt[x^2 + y^2], y/Sqrt[x^2 + y^2]}, {x, -5, 5}, {y, -5, 5}]

I want to use a VectorScaling-option such that vectors are displayed accoring to their length. Obviously, all vectors in this specific vector plot should have the same length, as they are normalized. I tried to achieve this using the options

VectorScaling->Automatic

This yields the following output:
VectorSclaing Automatic
The vectors have different lengths (and the colors match this). Why does this happen? The options "Linear", "Log" and "Sqrt" yield similar results. Is this an artifact of calculation inaccuracies? If so, how may I compensate for this?
If I don't use any VectorScaling-option, then all the vectors have the same length (which is the default), but the colors still vary.
I'm using Wolfram Mathematica 12.3.

Addendum: I understand that getting rid of "VectorScaling->Automatic" would yield vectors of constant length. Though I'd like to plot three different vector fields in such a way, that the length of the plottet vectors relates to the real length. So I need some sort of vector scaling for this field of constant length, too.

$\endgroup$
6
  • $\begingroup$ Related: mathematica.stackexchange.com/q/239039/4999. This has some discussions of the older VectorScale option that might be helpful: mathematica.stackexchange.com/q/71787/4999 $\endgroup$
    – Michael E2
    Commented Jun 25, 2021 at 14:08
  • $\begingroup$ Yeah, at the end I just downloaded Mathematica 11 which did the job. Don't know how to achieve what I wanted in 12.3. VectorScaling->Automatic does not do the job if you want other vectorplots with the same scaling to compare them. @MichaelE2 $\endgroup$
    – Babelfish
    Commented Jun 25, 2021 at 15:25
  • 1
    $\begingroup$ Your vectors aren't all the same length. :-) They vary from 0.9999999999999998 to 1.0000000000000002 in length. Floating point math is fun. $\endgroup$ Commented Jun 25, 2021 at 15:53
  • $\begingroup$ Yes, that's what I guessed, too. Can I explicitley tell Mathematica how to map vector length to arrow length? $\endgroup$
    – Babelfish
    Commented Jun 25, 2021 at 16:20
  • $\begingroup$ VectorScale -> None gives constant lengths. $\endgroup$
    – tad
    Commented Jun 10 at 23:46

1 Answer 1

0
$\begingroup$
f1[x_, y_] := x/Sqrt[x^2 + y^2];
f2[x_, y_] := y/Sqrt[x^2 + y^2];



p1 = VectorPlot[{f1[x, y], f2[x, y]}, {x, -5, 5}, {y, -5, 5}, 
      VectorScale -> {Automatic, Automatic, #1 &}, ImageSize -> Medium]

enter image description here

p2 = VectorPlot[{f1[x, y], f2[x, y]}, {x, -5, 5}, {y, -5, 5}, 
  VectorScale -> {Automatic, Automatic, #2 &}, ImageSize -> Medium]

enter image description here

Finally

Show[p1, p2]

enter image description here

$\endgroup$
2
  • $\begingroup$ @ Babelfish i hope this solve it ! $\endgroup$
    – Alrubaie
    Commented May 26, 2021 at 13:08
  • $\begingroup$ Ahem, I think I did not formulate my problem explicitly enough. Your plot shows vectors of different length - but they should all have the same length. Though I don't really understand whats going on, anyway. $\endgroup$
    – Babelfish
    Commented May 26, 2021 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.