I'm trying to plot the electric and magnetic fields of a relativistically moving electric charge using VectorPlot3D, and apply "Manipulate" to change the velocity. The code I'm using is as follows:

EE[x_,y_,z_,v_,t_] = {((1 - v^2)*x)/((t - v*z)^2 + (1 - v^2)*(-t^2 + x^2 + y^2 + z^2))^(3/2), 
 ((1 - v^2)*y)/((t - v*z)^2 + (1 - v^2)*(-t^2 + x^2 + y^2 + z^2))^(3/2), 
 ((1 - v^2)*(-t*v + z))/((t - v*z)^2 + (1 - v^2)*(-t^2 + x^2 + y^2 + z^2))^(3/2)}

VectorPlot3D[{EE[x, y, z, 0, 0.1], Cross[{0, 0, 0.1}, EE[x, y, z, 0, 0.1]]},
 {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, ImageSize -> Large, 
 VectorScale -> {0.25, Scaled[0.5], Automatic},
 RegionFunction -> Function[{x, y, z}, x^2 + y^2 + (z)^2 > (0.3)^2]]

This gives me a plot like this, with the electric field in blue and the magnetic field in brown:

enter image description here

The vector fields have the right sort of shape, but I'm having trouble with the scalings of the two vector fields. The magnitude of the magnetic field should be no greater than $v$ times the magnitude of the electric field ($v = 0.1$ in this example code.) However, Mathematica always seems to rescale the two vector fields so that the largest vectors are the same size, which makes the magnetic fields always appear to have the same magnitude as the electric fields (as you can see in the output.)

Ideally, what I'm hoping to eventually do is drop this whole thing into a Manipulate function where I can slide v up and down and show how the magnetic fields get larger as $v$ increases, but I can't do this if Mathematica is "helpfully" rescaling the vector fields for me. I've played around with VectorScale, but it only seems to accept one list of arguments; if I try to give it a list of parameters for each vector field, it complains that I've given it an invalid VectorScale specification.

So, my question: Is there a way to independently control the scaling of multiple vector fields in VectorPlot3D?

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – user9660
    Apr 16, 2015 at 15:58
  • 1
    $\begingroup$ You can always make two separate vector plots and then combine them with Show. $\endgroup$
    – Virgil
    Apr 16, 2015 at 20:22

1 Answer 1


As Virgil stated in his comment, one way to accomplish this is by making two vector plots and combining them with Show

   EE[x, y, z, 0, 0.1], {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
   ImageSize -> Large,
   VectorScale -> {0.25, Scaled[0.5], Automatic}, 
   RegionFunction -> Function[{x, y, z}, x^2 + y^2 + (z)^2 > (0.3)^2]],
  VectorPlot3D[Cross[{0, 0, 0.1}, EE[x, y, z, 0, 0.1]],
   {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
   VectorStyle -> ColorData[97][2], 
   VectorScale -> {sf .25, Scaled[0.5], Automatic}, 
   RegionFunction -> 
    Function[{x, y, z}, x^2 + y^2 + (z)^2 > (0.3)^2]]
  ], {{sf, .5, "Scaling Factor"}, 0.01, 2}]

enter image description here

This may be the best way to accomplish this, as VectorPlot3D doesn't accept two different lists for the VectorScale option.


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.