# DensityPlot Increase Information

I am trying to make a density plot in Mathematica, however the distribution of the plot is not as visible as I would like. I plotted the same function in python and it contains a greater visible range of information. This can be seen in the first picture below. When I try the same plot in Mathematica some information is lost. I cant see the decrease in intensity on either side of the central bright spot. I am using PlotRange "All" and I can adjust the plot range but I get large white spots where I am outside of the plot range. I am not sure how to tackle the problem if anyone has any ideas I would appreciate your thoughts!

My code is as follows

DensityPlot[di, {x, -5, 5}, {y, -5, 5}, PlotLegends -> Automatic,
ColorFunction -> "Rainbow", PlotRange -> All]


Thanks, Ben • Have you tried increasing the plot range, like DensityPlot[di, {x, -20, 20}, {y, -20, 20}]? Also could you give the explicit expression of di? – Silvia Jan 12 '14 at 0:45
• Without the definition of di we can't help you much. You can try using different color functions. The two darker spots on the left and right from your reference image can actually be seen as more reddish spots in your mathematica plot. If you want to replicate the jet color scheme you can generate it with code from this example and then use it with ColorFunction->jet. – shrx Jan 12 '14 at 1:14
• Here is the entire code. In creasing the plot range does not reduce the effect but thanks for the suggestion. z = 100; r = Sqrt[x^2 + y^2 + z^2]; theta = ArcCos[z/r]; phi = ArcTan[y/x]; gama = 40; beta = Sqrt[1 - (1/(gama^2))] di = ((Sin[phi]^2) + ((Cos[theta] - beta)^2* Cos[phi]^2)/(1 - beta*Cos[theta])^2)/((1 - beta*Cos[theta])^3* gama^4) – user1558881 Jan 12 '14 at 1:32
• I dont see how knowing di could help, it could be any function, I believe solving the issue lies in plotting. – user1558881 Jan 12 '14 at 1:34
• I suppose it's because DensityPlot is working correctly, and for it to be adjusted the way you want it, it would be helpful to have the actual function. To get the sort of lines in your objective image, consider ContourPlot. You also might construct a custom ColorFunction. – Michael E2 Jan 12 '14 at 2:07

As said in the comments, you can use a different ColorFunction, or you can rescale the data used to calculate the color function, or you can use ContourPlot instead. Here is an example of using a different ColorFunction and rescaling the data:

jet[u_?NumericQ] :=
Blend[{{0, RGBColor[0, 0, 9/16]}, {1/9, Blue}, {23/63, Cyan}, {13/21,
Yellow}, {47/63, Orange}, {55/63, Red}, {1,
RGBColor[1/2, 0, 0]}}, u] /; 0 <= u <= 1

DensityPlot[di, {x, -15, 15}, {y, -12, 12}, PlotLegends -> Automatic,
PlotPoints -> 100, ColorFunction -> (jet[(#)^.4] &),
PlotRange -> All, AspectRatio -> 24/30, ImageSize -> 600] And here it is using rescaled data with ContourPlot:

ContourPlot[di, {x, -15, 15}, {y, -12, 12}, PlotLegends -> Automatic,
PlotPoints -> 100, ColorFunction -> (jet[(#)^.4] &),
PlotRange -> All, AspectRatio -> 24/30, ImageSize -> 600,
Contours -> Table[x^(1/.7), {x, 0, 12500^.7, 5}],
ContourStyle -> None] I used the jet function scaling linked to by Shrx above. There are many parameters to adjust to make the resolution improve. This Manipulate shows the effect of changing few parameters. Manipulate[

DensityPlot[di, {x, -plotRange, plotRange}, {y, -plotRange, plotRange},
PlotLegends -> Automatic, PlotRange -> All,
ColorFunction -> (jet[(#)^scale] &), PerformanceGoal -> "Quality",
PlotPoints -> plotPoints, MaxRecursion -> maxRecursion,
ColorFunctionScaling -> True, Mesh -> False, ClippingStyle -> Automatic,
ImageSize -> 600],

{{scale, .5, "scale?"}, .1, 1, .01, Appearance -> "Labeled"},
{{plotPoints, 50, "plotPoints?"}, 10, 300, 1, Appearance -> "Labeled"},
{{maxRecursion, 10, "MaxRecursion?"}, 2, 14, 1, Appearance -> "Labeled"},
{{plotRange, 5, "plot range?"}, 5, 15, 1, Appearance -> "Labeled"},
ContinuousAction -> False,
Initialization :>
(
z = 100; r = Sqrt[x^2 + y^2 + z^2]; theta = ArcCos[z/r]; phi = ArcTan[y/x];
gama = 40;
beta = Sqrt[1 - (1/(gama^2))];
di = ((Sin[phi]^2) + ((Cos[theta] - beta)^2*
Cos[phi]^2)/(1 - beta*Cos[theta])^2)/((1 - beta*Cos[theta])^3*gama^4);
jet[u_?NumericQ] :=
Blend[{{0, RGBColor[0, 0, 9/16]}, {1/9, Blue}, {23/63, Cyan}, {13/21, Yellow},
{47/63, Orange}, {55/63, Red}, {1, RGBColor[1/2, 0, 0]}}, u] /; 0 <= u <= 1
)
] 