2
$\begingroup$

I am trying to plot a vector graph such that that vectors closest to the origin are opaque, and those furthest from the origin are transparent. I have tried using opacity with a function inside of it:

VectorPlot3D[1/(1 + Sqrt[x^2 + y^2 + z^2])
HeavisideTheta[
z - 3/2 (1/10) (x^2 + y^2)]*{1/
 3 E^-z (-(1/2) Sqrt[3] Sin[(Sqrt[3] x)/2 - y/2] - 
   1/2 Sqrt[3] Sin[(Sqrt[3] x)/2 + y/2]), 
1/3 E^-z (1/2 Sin[(Sqrt[3] x)/2 - y/2] - 
   1/2 Sin[(Sqrt[3] x)/2 + y/2] - Sin[y]), -(1/3)
   E^-z (Cos[(Sqrt[3] x)/2 - y/2] + Cos[(Sqrt[3] x)/2 + y/2] + 
   Cos[y])} + 1/(1 + Sqrt[x^2 + y^2 + z^2])
HeavisideTheta[
3/2 (1/10) (x^2 + y^2) - z]*{-(1/3) E^
 z (-(1/2) Sqrt[3] Sin[(Sqrt[3] x)/2 - y/2] - 
   1/2 Sqrt[3] Sin[(Sqrt[3] x)/2 + y/2]), -(1/3) E^
 z (1/2 Sin[(Sqrt[3] x)/2 - y/2] - 1/2 Sin[(Sqrt[3] x)/2 + y/2] - 
   Sin[y]), -(1/3) E^
 z (Cos[(Sqrt[3] x)/2 - y/2] + Cos[(Sqrt[3] x)/2 + y/2] + 
   Cos[y])}, {x, -1 \[Pi], 1 \[Pi]}, {y, -1.5 \[Pi], 1.5 \[Pi]}, {z, -2, 1.5}, VectorStyle -> {Black, Opacity[Function[{x,y,z},1/(1+x*y*z)]}, Axes -> True, AxesOrigin -> {0, 0, 0}, Boxed -> False, VectorPoints -> 10, ImageSize -> Large, VectorScale -> 0.04, ViewPoint -> Front]

As well as using the GrayLevel function to try and create functional dependence to just make the outer vectors more grey.

Neither of these approaches seem to be working.

VectorPlot3D[1/(1 + Sqrt[x^2 + y^2 + z^2])
HeavisideTheta[
z - 3/2 (1/10) (x^2 + y^2)]*{1/
 3 E^-z (-(1/2) Sqrt[3] Sin[(Sqrt[3] x)/2 - y/2] - 
   1/2 Sqrt[3] Sin[(Sqrt[3] x)/2 + y/2]), 
1/3 E^-z (1/2 Sin[(Sqrt[3] x)/2 - y/2] - 
   1/2 Sin[(Sqrt[3] x)/2 + y/2] - Sin[y]), -(1/3)
   E^-z (Cos[(Sqrt[3] x)/2 - y/2] + Cos[(Sqrt[3] x)/2 + y/2] + 
   Cos[y])} + 1/(1 + Sqrt[x^2 + y^2 + z^2])
HeavisideTheta[
3/2 (1/10) (x^2 + y^2) - z]*{-(1/3) E^
 z (-(1/2) Sqrt[3] Sin[(Sqrt[3] x)/2 - y/2] - 
   1/2 Sqrt[3] Sin[(Sqrt[3] x)/2 + y/2]), -(1/3) E^
 z (1/2 Sin[(Sqrt[3] x)/2 - y/2] - 1/2 Sin[(Sqrt[3] x)/2 + y/2] - 
   Sin[y]), -(1/3) E^
 z (Cos[(Sqrt[3] x)/2 - y/2] + Cos[(Sqrt[3] x)/2 + y/2] + 
   Cos[y])}, {x, -1 \[Pi], 1 \[Pi]}, {y, -1.5 \[Pi], 1.5 \[Pi]}, {z, -2, 1.5}, VectorStyle -> {GrayLevel[Sqrt[x^2 + y^2 + z^2]], Opacity[1]}, Axes -> True, AxesOrigin -> {0, 0, 0}, Boxed -> False, VectorPoints -> 10, ImageSize -> Large, VectorScale -> 0.04, ViewPoint -> Front]

Sorry about the lack of formatting. It got lost copying it over. Thanks in advance!

$\endgroup$
3
$\begingroup$

Remove the option VectorStyle and add the options VectorColorFunctionScaling -> False and VectorColorFunction -> Function[{x, y, z}, Opacity[1/(1 + x*y*z), Black]] (better yet, as suggested by MelaGo in comments Function[{x, y, z}, Opacity[1/Norm[{x,y,z}], Black]) to get

enter image description here

$\endgroup$
  • 2
    $\begingroup$ Or alternatively Opacity[1/(Norm[{x, y, z}]), Black] $\endgroup$ – MelaGo Jul 1 at 4:49
  • $\begingroup$ Thank you @MelaGo; I added your suggestion. $\endgroup$ – kglr Jul 1 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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