2
$\begingroup$

I am trying to plot a heatmap from the following code. I have a problem where the colour seems to stop before reaching the corners. Please can someone help me to make the colour run all the way to the edge? Also, am I doing something wrong with the axis labels? Why do they not appear as "x" and "y"? Thanks!

n = 100;
a = 1.05;
γ[a_, x_] := Gamma[a] - Gamma[a, x]
ρc[x_, y_, n_] := 
 Sqrt[2/π]*Gamma[n - 1, x^2 + y^2]/Gamma[n - 1]*Abs[y]*Exp[2*y^2]*
  Erfc[Sqrt[2]*Abs[y]]

Show[
  DensityPlot[
    ρc[x, y, n], 
    {x, -a*Sqrt[n], a*Sqrt[n]}, {y, -a*Sqrt[n], a*Sqrt[n]}, 
    ScalingFunctions -> "Log", 
    ColorFunction -> "Rainbow", PlotLegends -> Automatic, 
    AxesLabel -> {x, y}
  ], 
  Graphics[
    {Black, Thick, Circle[{0, 0}, Sqrt[n]]},
    {Red, Thick, Line[{-Sqrt[n], 0}, {Sqrt[n], 0}]}
  ]
]
$\endgroup$

1 Answer 1

2
$\begingroup$

Increase PlotPoints

FrameLabel instead of Axeslabel

Some bracketing mistakes inside Graphics

I had to omit ScalingFunctions -> "Log" to get a result which is in accordance with Graphics

pl =
 DensityPlot[\[Rho]c[x, y, n], {x, -a*Sqrt[n], 
   a*Sqrt[n]}, {y, -a*Sqrt[n], a*Sqrt[n]},
  ColorFunction -> "Rainbow",
  PlotLegends -> Automatic,
  PlotPoints -> 60,
  FrameLabel -> {x, y}];

gr =
  Graphics[{{Black, Thick, Circle[{0, 0}, Sqrt[n]]}, {Red, Thick, 
     Line[{{-Sqrt[n], 0}, {Sqrt[n], 0}}]}}];


Show[pl, gr]

enter image description here

$\endgroup$
5
  • $\begingroup$ See current update $\endgroup$
    – eldo
    Sep 18 at 15:15
  • $\begingroup$ Thank you! (+1) $\endgroup$
    – MarcoB
    Sep 18 at 15:17
  • $\begingroup$ You're most welcome $\endgroup$
    – eldo
    Sep 18 at 15:18
  • $\begingroup$ Thank you very much! Is there any way I can make the axis label and numbers larger? $\endgroup$
    – Gwaine
    Sep 18 at 15:25
  • $\begingroup$ Add the option LabelStyle -> 12 $\endgroup$
    – eldo
    Sep 18 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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