0
$\begingroup$

I'd like to scale with independent parameters the vectors and the corresponding arrowheads in a vector plot. The basic code is as follows:

vecP = 9;
disk = 1.4;
vecScale = .1;
arrScale = .8;
thickn = 0.007;

toPlot[x, y]:=(4 E^(2 Im[ArcTan[x, y]] + 2 Re[-x^2 - y^2]) Abs[x^2 + y^2])/\[Pi];

vpm1 = VectorPlot[
   toPlot[x, y] {y, -x}, {x, y} \[Element] Disk[{0, 0}, disk], 
   VectorPoints -> vecP, 
   VectorScale -> {vecScale, arrScale}, 
   VectorStyle -> {Black, Thickness[thickn]}, 
   ]

Of course the above code doesn't work, as the "arrScale" parameter assigns a fixed dimension to each arrowhead in the plot (while vecScale is actually scaling the vectors).

What I'd like to do is to scale the arrowheads as well, but with a different scaling coefficient respect to the vector scaling.

I thought of doing something like:

VectorScale -> {vecScale, arrScale * #&}

as one would do in a ColorFunction approach:

ColorFunction -> (Blend[{White,Black}, #] &)

where the slot #& is referred to the plotted function's value point by point. However, this approach doesn't work in my specific case (if someone can explain me why I'd be glad :) ).

$\endgroup$
4
  • $\begingroup$ Possible duplicate: mathematica.stackexchange.com/q/788/12 $\endgroup$
    – Szabolcs
    Oct 10, 2019 at 7:33
  • $\begingroup$ @Szabolcs thx for the link, I came across it before posting but I don't think it answer my question. I'm not 100% sure, but I think scaling the arrows in a Graphic (as in the link) or in a VectorPlot. Also, that post is very old and things might have changed in the meanwhile! $\endgroup$
    – Fraccalo
    Oct 10, 2019 at 7:40
  • 1
    $\begingroup$ Things didn't change regarding the link I gave, but you are right: I misread your question. The link is not relevant. (Just to be clear, I did not vote to close as duplicate, I merely gave the link.) $\endgroup$
    – Szabolcs
    Oct 10, 2019 at 8:17
  • $\begingroup$ @Szabolcs I really appreciate the community job here (therefore I don't get it personal even if someone votes to close my posts, I think it's perfectly normal and it might happen to everyone to post a duplicate!) and I embrace the "Possible duplicate" links as useful suggestions rather than personal critiques, so really no hard feelings :D $\endgroup$
    – Fraccalo
    Oct 10, 2019 at 8:28

1 Answer 1

2
$\begingroup$

I think I might have found a solution: the second option of VectorScale has to be given with the Scaled function as follows:

VectorPlot[toPlot[x, y] {y, -x}, {x, y} \[Element] Disk[{0, 0}, disk],
 VectorPoints -> vecP, 
 VectorScale -> ({vecScale, Scaled[arrScale], Automatic}), 
 VectorStyle -> {Black, Thickness[thickn]}]

This "decouples" the vectors' length and the arrowheads' dimension. (This is not exactly true, as they are still somehow coupled, but one has enough parameters to customise the arrows as he wants!)

$\endgroup$

Your Answer

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

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