4
$\begingroup$

I'm having troubles in adjusting the colors shades/contrast/hue of the following typical plot:

enter image description here

enter image description here

As you can see, there are two dark regions above and under the central part. I need to accentuate their luminosity (on the black background/first image) to see those areas more clearly, just as shown on the Wikipedia page; see this image, for the orbital (3,1,0).

Or equivalently, darken the pale yellowish regions on the white background (second image) if possible.

The graphics have been created with Mathematica 13.2, using a version of the code from 300318:

So how can I make the darker regions to stand-out, i.e to be more visible? I prefer a dark region on a white background (like the second image), and I may accept to increase the central part too to reveal the subtle regions.

$\endgroup$
5
  • 1
    $\begingroup$ Check ColorFunction and ColorFunctionScaling. $\endgroup$ Commented Mar 11 at 18:13
  • $\begingroup$ Are your wave functions same as on Wikipedia? $\endgroup$ Commented Mar 11 at 18:27
  • $\begingroup$ @azerbajdzan, yes, the plots are the same, except for the color shades. $\endgroup$
    – Cham
    Commented Mar 11 at 18:29
  • $\begingroup$ I think it has nothing to do with color function you use but with the definition of wave functions you use. On Wikipedia they most likely used a different definition. $\endgroup$ Commented Mar 11 at 19:23
  • $\begingroup$ @azerbajdzan, nope, the wave function is exactly the same. It is given in the upper-right corner of the Wikipedia image. $\endgroup$
    – Cham
    Commented Mar 11 at 20:28

1 Answer 1

5
$\begingroup$

Update:

Simpler version of the code with ColorFunctionScaling -> {0, Pi^2} and for some reason also plot points had to be increased to PlotPoints -> 300 to achieve the same quality.

NormFactor[n_, l_] := Sqrt[Factorial[n - l - 1]/(2 n Factorial[n + l])]

Psi[n_, l_, m_, u_, \[Theta]_, \[Phi]_] := 
 NormFactor[n, l] Exp[-u/2] u^l LaguerreL[n - l - 1, 2 l + 1, 
   u] SphericalHarmonicY[l, m, \[Theta], \[Phi]]

u[x_, z_] := Sqrt[x^2 + z^2]
theta[x_, z_] := ArcTan[z, x]

With[{nn = 3, nl = 1, nm = 0}, 
 DensityPlot[
  Abs[Psi[nn, nl, nm, u[x, z], theta[x, z], 0]]^2, {x, -15, 
   15}, {z, -15, 15}, Frame -> None, Axes -> False, PlotRange -> All, 
  Ticks -> None, PlotPoints -> 300, ColorFunctionScaling -> {0, Pi^2},
   ColorFunction -> "SunsetColors", ImageSize -> {400, 400}]]

enter image description here

With ColorFunction -> GrayLevel:

enter image description here

With ColorFunction -> (GrayLevel[1 - #] &):

enter image description here

Old version:

So I think that they are simply clipping the range of the color gradient (that also explain the big white areas on their images).

The constant 0.005637338004403787 is the max value of the function and the clipping constant is Pi^2 or could be just, say, 9 or 10. Also you have to use ColorFunctionScaling -> False for a proper effect of clipping of the gradient.

With[{nn = 3, nl = 1, nm = 0}, 
 DensityPlot[Pi^2/
    0.005637338004403787` Abs[
     Psi[nn, nl, nm, u[x, z], theta[x, z], 0]]^2, {x, -15, 
   15}, {z, -15, 15}, Frame -> None, Axes -> False, PlotRange -> All, 
  Ticks -> None, PlotPoints -> 120, ColorFunctionScaling -> False, 
  ColorFunction -> "SunsetColors", ImageSize -> {400, 400}]]

enter image description here

My image is almost unrecognizable form the one on Wikipedia:

enter image description here

With ColorFunction -> ColorData[{"GrayTones", "Reverse"}] you get:

enter image description here

$\endgroup$
5
  • $\begingroup$ @Cham: The real depiction is your image. They increased contrast in some parts but then loose contrast elsewhere... in the white areas which seem now be constant, but in fact they are not constant as can be seen on your original image. $\endgroup$ Commented Mar 11 at 20:44
  • $\begingroup$ Please, could you explain the ColorFunctionScaling -> {0, Pi^2}? Why $\pi^2$? $\endgroup$
    – Cham
    Commented Mar 12 at 12:08
  • 1
    $\begingroup$ @Cham: I think it is just coincidence, I tried to find a constant that resembles the Wikipedia image the most and it turned out to be near $\pi^2$, but as I wrote also in my answer it could be 9 or 10 without too much difference. The constant just determines the clipping point in the gradient. If you use 1 as the constant you get exactly your original image without any clipping. $\endgroup$ Commented Mar 12 at 14:30
  • $\begingroup$ Just for a last step polishing, what if you want to use a reversed GrayLevel as shade? Currently, the option ColorFunction -> ColorData[{"GrayTones", "Reverse"}] produces a yellowish gray. I would like to get a white background, instead of that beige looking version (see your last picture above). $\endgroup$
    – Cham
    Commented Mar 12 at 15:47
  • 1
    $\begingroup$ @Cham: I added those cases into the answer. $\endgroup$ Commented Mar 12 at 15:56

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.