3
$\begingroup$

I'm generating some figures for a paper. One of them has a pattern like the following figure:

DensityPlot[
 Abs[Exp[-Sqrt[x^2 + y^2]/5] BesselJ[0, Sqrt[x^2 + y^2]]], {x, -20, 
  20}, {y, -20, 20}, ColorFunction -> "SunsetColors", 
 PlotPoints -> 100, PlotRange -> All, PlotRangePadding -> 0, 
 FrameTicksStyle -> 
  Directive[FontFamily -> "Arial", 12, Plain, Thick], 
 ImageSize -> {Automatic, 150}]

modulated Bessel beam

Since the magnitude in the middle could be much higher than that in the outer region, some rings cannot be seen if I print it. In addition, since the pattern represents magnitude, I prefer a kind of "hot" color map to render these data. How can I solve the problem such that the pattern can be seen clearly on a printed copy?

$\endgroup$
2
  • $\begingroup$ "large data"--I think it may be better to say "wide dynamic range" or something like that; what do you think? $\endgroup$
    – acl
    Commented Apr 2, 2013 at 16:08
  • $\begingroup$ yes, you are right. I should say clearly. sorry about that. $\endgroup$
    – Tony Dong
    Commented Apr 2, 2013 at 16:33

2 Answers 2

5
$\begingroup$

ColorFunction takes an actual function as input. Thus, eg,

Manipulate[
 DensityPlot[
  Abs[Exp[-Sqrt[x^2 + y^2]/5] BesselJ[0, Sqrt[x^2 + y^2]]], {x, -20, 
   20}, {y, -20, 20}, 
  ColorFunction -> Function[{f}, RGBColor[#, #, #] &@(f^alpha)], 
  PlotPoints -> 100, PlotRange -> All, PlotRangePadding -> 0, 
  FrameTicksStyle -> 
   Directive[FontFamily -> "Arial", 12, Plain, Thick], 
  ImageSize -> {Automatic, 150}],
 {{alpha, .2}, 0.01, 2}
 ]

Mathematica graphics

or with SunsetColors:

Manipulate[
 DensityPlot[
  Abs[Exp[-Sqrt[x^2 + y^2]/5] BesselJ[0, Sqrt[x^2 + y^2]]], {x, -20, 
   20}, {y, -20, 20}, 
  ColorFunction -> (ColorData["SunsetColors"][#^alpha] &), 
  PlotPoints -> 100, PlotRange -> All, PlotRangePadding -> 0, 
  FrameTicksStyle -> 
   Directive[FontFamily -> "Arial", 12, Plain, Thick], 
  ImageSize -> {Automatic, 150}],
 {{alpha, .2}, 0.01, 2}
 ]

Mathematica graphics

$\endgroup$
3
$\begingroup$

Two possibilities:

DensityPlot[Abs[Exp[-Sqrt[x^2 + y^2]/5] BesselJ[0, Sqrt[x^2 + y^2]]]^(
 1/4), {x, -20, 20}, {y, -20, 20},
 ColorFunction -> "SunsetColors",
 PlotPoints -> 100, PlotRange -> All, PlotRangePadding -> 0, 
 FrameTicksStyle -> 
  Directive[FontFamily -> "Arial", 12, Plain, Thick], 
 ImageSize -> {Automatic, 150}]

sqrt

DensityPlot[
 20 Abs[Exp[-Sqrt[x^2 + y^2]/5] BesselJ[0, Sqrt[x^2 + y^2]]], {x, -20,
   20}, {y, -20, 20},
 ColorFunction -> "SunsetColors",
 ColorFunctionScaling -> False,
 PlotPoints -> 100, PlotRange -> All, PlotRangePadding -> 0, 
 FrameTicksStyle -> 
  Directive[FontFamily -> "Arial", 12, Plain, Thick], 
 ImageSize -> {Automatic, 150}]

cutoff

In the first attempt, I raised the small values by taking the fourth root of the Abs. In the second version, I turned off ColorFunctionScaling and multiplied by 20 to raise the small values. In that case, the hight values are cut off.

You can replace the power 1/4 in the first version by 1/2 to darken the lower values.

$\endgroup$

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.