2
$\begingroup$

Consider the following code :

\[HBar]\[Omega] = 1;

    EXIni[p_, 
   Theta_] := \[HBar]\[Omega]/
    2*(3 (1 - p)^3 (Cos[Theta/2]^2 - Sin[Theta/2]^2) + 
     3 p^3 (Sin[Theta/2]^2 - Cos[Theta/2]^2) + 
     3*(p (1 - p)^2 (Cos[Theta/2]^2 - Sin[Theta/2]^2) + 
        p^2 (1 - p) (Sin[Theta/2]^2 - Cos[Theta/2]^2)));

EXFin[p_, Theta_] := 
  3*\[HBar]\[Omega]/
    2*(((1 - p)^3 + 3*p (1 - p)^2)*(Cos[Theta/2]^2 - 
        Sin[Theta/2]^2) + (p^3 + 3*p^2 (1 - p))*(Sin[Theta/2]^2 - 
        Cos[Theta/2]^2));

DeltaEX[p_, Theta_] := EXFin[p, Theta] - EXIni[p, Theta];

Show[Graphics3D[
  MapThread[{Black, Arrow@Tube@{{0, 0, 0}, #1}, 
     Text[#2, #1, {0, -2}, 
      BaseStyle -> {FontSize -> 28}]} &, {2 IdentityMatrix[3], {x, y, 
     z}}], Boxed -> False, ImageSize -> Large, Lighting -> None], 
 SphericalPlot3D[1, {Theta, 0, \[Pi]}, {Phi, 0, 2*\[Pi]}, 
  ColorFunction -> 
   Function[{x, y, z, Theta, Phi}, 
    ColorData[{"TemperatureMap", {-0.216, 0.216}}][
     DeltaEX[0.1, Theta]]], Boxed -> False, 
  PlotStyle -> Directive[Opacity[1]], ColorFunctionScaling -> False, 
  ImageSize -> Large, PlotPoints -> 120, MaxRecursion -> 10, 
  Mesh -> False, 
  PlotLegends -> 
   BarLegend[{"TemperatureMap", {-0.216, 0.216}}, 
    LabelStyle -> {FontSize -> 30}]]]

It gives me the following plot :

enter image description here

As you an see, I have a weird lighting even if I put Lighting->None (for example the equatorial plane of the sphere is not fully white, it has some clear white-grey color variation).

How can I remove this effect ? I want a neutral plot.

$\endgroup$
  • $\begingroup$ Your code does not reproduce the image shown for me (I get a uniformly gold colored sphere), but try Lighting -> {{"Ambient", White}} in SphericalPlot3D $\endgroup$ – Michael E2 May 17 at 14:38
  • $\begingroup$ @MichaelE2 I forgot to add hbar omega=1 (see my edited post), it should work with it. Unfortunately your trick doesn't change much the graph. $\endgroup$ – StarBucK May 17 at 15:27
  • 2
    $\begingroup$ Put the Lighting -> {{"Ambient", White}} in the SphericalPlot3D instead of the Graphics3D, then it works. Note that only your arrows are in Graphics3D and your SphericalPlot3D is seperately included in Show $\endgroup$ – Ruud3.1415 May 17 at 15:32
  • $\begingroup$ @Ruud3.1415 indeed ! Thanks ! Could you explain me why to put it in Graphics3D doesn't work ? And what this command actually does in comparison of lightning none $\endgroup$ – StarBucK May 17 at 15:33
  • $\begingroup$ closely related: Option Lighting in the Show function does not work $\endgroup$ – kglr May 18 at 4:15
5
$\begingroup$

Around V10, different objects in 3D graphics could be given individual lighting specs. The 3D plotting functions specify their own lighting, which they do by default if the user does not specify a lighting. This will override when using Show[] any settings that might be inherited from earlier graphics or explicitly set options. Usually the lighting is a colored lighting depending on the plot theme, but if ColorFunction is specified, the lighting seems to be set to "Neutral". So to override this behavior, you have to specify the lighting in the plotter, which I suggested in my comment.

So put Lighting -> {{"Ambient", White}} in SphericalPlot3D:

Show[Graphics3D[
  MapThread[{Black, Arrow@Tube@{{0, 0, 0}, #1}, 
     Text[#2, #1, {0, -2}, 
      BaseStyle -> {FontSize -> 28}]} &, {2 IdentityMatrix[3], {x, y, 
     z}}], Boxed -> False, ImageSize -> Large, Lighting -> None], 
 SphericalPlot3D[1, {Theta, 0, \[Pi]}, {Phi, 0, 2*\[Pi]}, 
  ColorFunction -> 
   Function[{x, y, z, Theta, Phi}, 
    ColorData[{"TemperatureMap", {-0.216, 0.216}}][
     DeltaEX[0.1, Theta]]], Boxed -> False, 
  PlotStyle -> Directive[Opacity[1]], ColorFunctionScaling -> False, 
  ImageSize -> Large, PlotPoints -> 120, MaxRecursion -> 10, 
  Mesh -> False, 
  PlotLegends -> 
   BarLegend[{"TemperatureMap", {-0.216, 0.216}}, 
    LabelStyle -> {FontSize -> 30}], 
  Lighting -> {{"Ambient", White}}]
 ]

enter image description here

$\endgroup$

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.