0
$\begingroup$

I am plotting 3D graphs wherein I have an equation with a variable parameter $m$ and I have to plot the graphs by taking 6 different values of the variable parameter. I am using color function TemperatureMap to show the different regions of the 3D plot. For $m=0$, I plot this graph and the colors on the graph are like this from bottom to top: navy blue, blue, red. Next I plot it for $m=1$, my colors become (from bottom to top) blue, very light blue, red. Every time I plot with a different value of $m$, the order of colors changes or get shifted. I don't have any other problem with it except that the color of the graph at $(q,p)=(0,0)$ changes everytime which causes ambiguity. How can I keep the colors constant everytime? Thank you.

\[Gamma] = q + I*p; 
z = 1; 
\[Theta] = Pi/4; 

m = 0; 
a0 = Sum[((1/(j!*l!))*Binomial[m, j]*Binomial[m, l]*
       Conjugate[z*Sin[\[Theta]]*Tan[\[Theta]]]^j*
              (-2*\[Gamma] + z*Cos[\[Theta]])^
        j*(-2*Conjugate[\[Gamma]] + Conjugate[z]*Cos[\[Theta]])^l*
              
       HypergeometricU[-l, 
        1 + j - l, (-2*\[Gamma] + 
           z*Cos[\[Theta]])*(-2*Conjugate[\[Gamma]] + 
                     Conjugate[z]*Cos[\[Theta]])]*(z*Sin[\[Theta]]*
          Tan[\[Theta]])^l)/
           ((-2*\[Gamma] + z*Cos[\[Theta]])*(-2*Conjugate[\[Gamma]] + 
          Conjugate[z]*Cos[\[Theta]]))^l, {j, 0, m}, 
         {l, 0, m}]/(E^(2*Abs[\[Gamma] - z*Cos[\[Theta]]]^2)*
          (Pi*Sum[((1/(k!*l!))*(-1)^k*Binomial[m, k]*Binomial[m, l]*
                    
           Conjugate[z*Sin[\[Theta]]*Tan[\[Theta]]]^
            l*((-z)*Cos[\[Theta]])^l*(Conjugate[z]*Cos[\[Theta]])^k*
                    
           HypergeometricU[-k, 
            1 - k + l, (-z)*Conjugate[z]*Cos[\[Theta]]^2]*
                    (z*Sin[\[Theta]]*Tan[\[Theta]])^k)/((-z)*
            Conjugate[z]*Cos[\[Theta]]^2)^k, {l, 0, m}, 
               {k, 0, m}])); 

p0 = Plot3D[a0 // Chop, {q, -4, 4}, {p, -4, 4}, PlotRange -> All, 
  ColorFunction -> "ThermometerColors"]

m = 1;

a1 = Sum[((1/(j!*l!))*Binomial[m, j]*Binomial[m, l]*
        Conjugate[z*Sin[\[Theta]]*Tan[\[Theta]]]^
         j*(-2*\[Gamma] + z*Cos[\[Theta]])^
         j*(-2*Conjugate[\[Gamma]] + Conjugate[z]*Cos[\[Theta]])^l*
               
        HypergeometricU[-l, 
         1 + j - l, (-2*\[Gamma] + 
            z*Cos[\[Theta]])*(-2*Conjugate[\[Gamma]] + 
            Conjugate[z]*Cos[\[Theta]])]*(z*Sin[\[Theta]]*
           Tan[\[Theta]])^l)/
            ((-2*\[Gamma] + 
           z*Cos[\[Theta]])*(-2*Conjugate[\[Gamma]] + 
           Conjugate[z]*Cos[\[Theta]]))^l, {j, 0, m}, {l, 0, m}]/
    E^(2*Abs[\[Gamma] - z*Cos[\[Theta]]]^2)/
      (Pi*
     Sum[((1/(k!*l!))*(-1)^k*Binomial[m, k]*Binomial[m, l]*
         Conjugate[z*Sin[\[Theta]]*Tan[\[Theta]]]^
          l*((-z)*Cos[\[Theta]])^l*(Conjugate[z]*Cos[\[Theta]])^k*
                
         HypergeometricU[-k, 
          1 - k + l, (-z)*Conjugate[z]*
           Cos[\[Theta]]^2]*(z*Sin[\[Theta]]*Tan[\[Theta]])^k)/((-z)*
          Conjugate[z]*Cos[\[Theta]]^2)^k, {l, 0, m}, {k, 0, m}]);



p1 = Plot3D[a1 // Chop, {q, -4, 4}, {p, -4, 4}, PlotRange -> All, 
  ColorFunction -> "ThermometerColors"]

$\endgroup$
1
  • 1
    $\begingroup$ Please post an example code. $\endgroup$
    – cvgmt
    Sep 22, 2022 at 10:15

1 Answer 1

2
$\begingroup$

Try the following changes in the definitions for p0 and p1:

p0 = Plot3D[a0 // Chop, {q, -4, 4}, {p, -4, 4}, PlotRange -> All, 
  ColorFunction -> (ColorData["ThermometerColors"][
      Rescale[#3, {0.0, 0.3}]] &), ColorFunctionScaling -> False]

p1 = Plot3D[a1 // Chop, {q, -4, 4}, {p, -4, 4}, PlotRange -> All, 
  ColorFunction -> (ColorData["ThermometerColors"][
      Rescale[#3, {0.0, 0.3}]] &), ColorFunctionScaling -> False]


GraphicsRow[{p0, p1}]

enter image description here


EDIT

For corresponding density plots:

p3 = DensityPlot[a0 // Chop, {q, -4, 4}, {p, -4, 4}
   , PlotRange -> All
   , ColorFunction -> (ColorData["ThermometerColors"][
       Rescale[#1, {0, 0.3}]] &)
   , ColorFunctionScaling -> False
   , PlotPoints -> 50
   ];

p4 = DensityPlot[a1 // Chop, {q, -4, 4}, {p, -4, 4}
   , PlotRange -> All
   , ColorFunction -> (ColorData["ThermometerColors"][
       Rescale[#1, {0, 0.3}]] &)
   , ColorFunctionScaling -> False
   , PlotPoints -> 50
   ];

GraphicsRow[{p3, p4}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thank you so much. It solved the problem. However, if I density plot using the same ColorFunction command which you used, it does not execute. I get the error "Slot number 3 in ColorData cannot be filled". Why is that and how can I fix it? $\endgroup$
    – Anaya
    Sep 23, 2022 at 5:56
  • $\begingroup$ @Anaya I have updated the answer. $\endgroup$
    – Syed
    Sep 23, 2022 at 6:37
  • 1
    $\begingroup$ Thank you so much $\endgroup$
    – Anaya
    Sep 28, 2022 at 10:22

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.