1
$\begingroup$

I use the following data

data3 = {{3 , 1, 1}, {18, 1, 2 }, {3 , 3, 4 }, {18 , 3, 3}}
ListDensityPlot[data3, InterpolationOrder -> 0]

enter image description here

when I multiplied x values to $10^{6}$ I get the wrong picture.

data3 = {{3  10^6, 1, 1}, {18  10^6, 1, 2 }, {3  10^6 , 3, 4 }, {18  10^6, 3, 3}}
ListDensityPlot[data3, InterpolationOrder -> 0]

enter image description here

Why it this happening and how to fix it?

$\endgroup$
1
  • $\begingroup$ try ListDensityPlot[data3, InterpolationOrder -> 0, ScalingFunctions -> {{# 10^-6 &, # 10^6 &}, "Linear"}]? $\endgroup$
    – kglr
    Apr 15 '20 at 12:38
3
$\begingroup$

When x and y coordinates have vastly different scales, plot functions can give unexpected results (see also: ListPlot3D weirdly distorts and loses plotting data).

A work-around is to use the option ScalingFunctions to make the x and y scales close to each other.

data3 = {{3 10^6, 1, 1}, {18 10^6, 1, 2}, {3 10^6, 3, 4}, {18 10^6, 3, 3}};

ListDensityPlot[data3, InterpolationOrder -> 0, 
 ScalingFunctions -> {{# 10^-6 &, # 10^6 &}, "Linear"}]

enter image description here

Alternatively,

ListDensityPlot[data3, InterpolationOrder -> 0, 
 ScalingFunctions -> { "Linear", {# 10^6 &, # 10^-6 &}}]

enter image description here

$\endgroup$

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.