1

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?

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

1 Answers1

3

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

kglr
  • 394,356
  • 18
  • 477
  • 896