I have a table of data of dimensions 150x51, each of the 150 points (frequency of a wave) corresponds to to 51 angles. I want to make a ListDensityPlot, and while the command on its own gives me the plot I want, I cannot understand how to change the value points of the axes.

DataRange kind does the job, but I want it to show more names of points. Ticks doesn't seem to work on ListDensityPlot . This is my command:

 ListDensityPlot[1 - RLfrl, ColorFunction -> "TemperatureMap", Frame -> True, PlotLegends -> BarLegend[{"TemperatureMap", {0, 1}}], DataRange -> {{0, Pi/2}, {0, 10^6}}, FrameLabel -> {"Angle of incidence [rad]", "Wave frequency  \[Omega] [\!\(\*SuperscriptBox[\(10\), \(6\)]\) \1/s]"}]    

and this is the picture I get:

enter image description here

Basically I want to refine the x-axis to show more points, and while we're at it, how can I tell him to show me the angles in rad, I.e instead of 1.57 to write π/2 ?

  • 2
    $\begingroup$ you need FrameTicks ( not Ticks) $\endgroup$ – kglr Jul 17 '18 at 9:43

You can use FindDivisions to find ticks that are integer multiples of Pi/2:

  • FindDivisions[{$x_{min}$, $x_{max}$}, $n$] finds a list of about $n$ "nice" numbers that divide the interval around $x_{min}$ to $x_{max}$ into equally spaced parts.
  • FindDivisions[{$x_{min}$, $x_{max}$, $dx$}, $n$] makes the parts always have lengths that are integer multiples of $dx$.


data = Table[Sin[x] Cos[ y/200], {y, 0, 1000, 1}, {x, 0, 4 Pi, 4 Pi/ 50}];
ListDensityPlot[data, DataRange -> {{0, 4 Pi}, {0, 1000}}, 
  FrameTicks -> {{Automatic, Automatic}, {FindDivisions[{0, 4 Pi, Pi/2}, 10], Automatic}}]

enter image description here

Compare with Range:

FindDivisions[{0, 2 Pi, Pi/4}, 7]

{0, π/2, π, (3 π)/2, 2 π}

Range[0, 2 Pi, Pi/4]

{0, π/4, π/2, (3 π)/4, π, (5 π)/4, (3 π)/2, (7 π)/4, 2 π}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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