6
$\begingroup$

I have some quantity varying with time (horizontal axis of the plot): it first oscillates then it has a jump (larger than the amplitude of the oscillations), then it continues oscillating. I have that quantity for a discrete set of cases (vertical axis of the plot).

I would like to find an option for ListDensityPlot that would allow me to really emphasize that jump: I don't want a nice smooth color scheme but rather one that would make the small oscillations invisible and would focus on the larger jump.

I can I control ListDensityPlot to do that ?

$\endgroup$
2
  • $\begingroup$ (List)DensityPlot is for a two-variable function such as $f(x,y)$, but from your description I understood that you have a single quantity varying in a single variable (time), i.e. $f(t)$. Can you clarify? I thought you had something like Plot[Table[Sin[x] + 3 UnitStep[x - 20] + i, {i, 0, 10, 2}] // Evaluate, {x, 0, 40}]. $\endgroup$
    – Szabolcs
    Commented Jul 24, 2012 at 10:19
  • 2
    $\begingroup$ It would be best if you could give an example, or maybe sample data (with as much information about the location of the jump as possible). $\endgroup$
    – Szabolcs
    Commented Jul 24, 2012 at 10:21

2 Answers 2

6
$\begingroup$

Sample data

pw = Piecewise[{{Sin[5 x + y], x < 5}, {3 + Sin[5 x + y], x > 5}}];

tab = Table[pw, {y, 0, 10, 0.1}, {x, 0, 10, 0.1}];

Expansion function

expand[c_ /; c == 0] = # &;
expand[c_] := 1/2 - ArcTan[c - 2 c #] / ArcTan[c] / 2 &

expand[x] generates a function with expansion factor x.

Table[
  Plot[expand[c][x], {x, 0, 1}],
  {c, 0, 10, 2}
] ~Partition~ 3 // Grid

Mathematica graphics

With expansion

We can use this on the data passed to the ColorFunction like this:

ListDensityPlot[tab, ColorFunction -> (ColorData["SunsetColors"] @ expand[10][#] &)]

Mathematica graphics

Without expansion

The same plot without expansion:

ListDensityPlot[tab, ColorFunction -> ColorData["SunsetColors"]]

Mathematica graphics

$\endgroup$
1
$\begingroup$

InterpolationOrder?

data = Table[
   With[{r = RandomReal[{0, 5}], 
     t = RandomReal[{0, 2 Pi}]}, {r Cos[t], r Sin[t], 
     Sin[r^2]/r^2}], {10^4}];


ListDensityPlot[data, Mesh \[Rule] None, InterpolationOrder -> 0]

Mathematica graphics

versus

ListDensityPlot[data, Mesh -> None, InterpolationOrder -> Automatic]

Mathematica graphics

$\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.