Message Boards Message Boards

0
|
3446 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:
GROUPS:

Why ListPlot3D is skimping on data and how to remedy it?

Posted 9 years ago

HI,

I have the following List of Lists:

In[73]:= maxmin[[1]]

Out[73]= {{2.3395, 2.13521, 2.27173, 2.81287, 2.25045, 2.26119, 
  2.34844, 2.44469}, {2.77805, 2.25561, 2.20846, 2.33292, 2.43347, 
  2.22756, 2.59013, 2.26579}, {2.22386, 2.79931, 2.12116, 2.11051, 
  2.29534, 2.62082, 2.09523, 2.15395}, {2.3066, 2.12227, 2.47889, 
  2.03011, 2.23263, 2.08004, 2.31913, 2.50845}, {1.9736, 2.23196, 
  2.14964, 2.18781, 2.40687, 2.0782, 2.30555, 2.31223}, {2.40094, 
  2.11356, 2.26898, 2.46934, 2.36108, 2.38895, 2.25621, 
  2.11581}, {2.19419, 2.38536, 2.57452, 2.26367, 2.64318, 2.01926, 
  2.69193, 2.38917}, {2.51357, 2.31244, 2.52476, 2.72018, 2.38392, 
  2.03368, 2.18047, 2.69192}}

So, it is 8x8 List. When I display it with ListPlot3D as:

ListPlot3D[maxmin[[1]] , InterpolationOrder -> {0, 0}, 
 PlotRange -> All]

I can see a 7x7 matrix. That is NOT good. What ways can I tell Mathematica to behave correctly? Thanks ahead, János

POSTED BY: Janos Lobb
2 Replies

Hi Janos,

the problem can be understood in the 1D case; with:

ListLinePlot[Range[8], InterpolationOrder -> 0]

one can see that within 8 data points lay basically only 7 levels. This is, because InterpolationOrder is set to 0. A quickfix could be to add a copy of the last data point to the data:

ListLinePlot[Append[Range[8], 8], InterpolationOrder -> 0]

Following this idea it means for your 2D case:

(* your data: *)
data = {{2.3395, 2.13521, 2.27173, 2.81287, 2.25045, 2.26119, 2.34844,
     2.44469}, {2.77805, 2.25561, 2.20846, 2.33292, 2.43347, 2.22756, 
    2.59013, 2.26579}, {2.22386, 2.79931, 2.12116, 2.11051, 2.29534, 
    2.62082, 2.09523, 2.15395}, {2.3066, 2.12227, 2.47889, 2.03011, 
    2.23263, 2.08004, 2.31913, 2.50845}, {1.9736, 2.23196, 2.14964, 
    2.18781, 2.40687, 2.0782, 2.30555, 2.31223}, {2.40094, 2.11356, 
    2.26898, 2.46934, 2.36108, 2.38895, 2.25621, 2.11581}, {2.19419, 
    2.38536, 2.57452, 2.26367, 2.64318, 2.01926, 2.69193, 
    2.38917}, {2.51357, 2.31244, 2.52476, 2.72018, 2.38392, 2.03368, 
    2.18047, 2.69192}};

(* adding copy of last column: *)
data9 = Append[#, Last[#]] & /@ data;
(* adding copy of last line: *)
data9 = Append[data9, Last[data9]];

In[34]:= data9 // Dimensions
    (* Out[34]= {9, 9} *)

ListPlot3D[data9, InterpolationOrder -> 0]

Maybe that helps, but I am quite sure there are less crude solutions (and curious to see!).

Regards -- Henrik

POSTED BY: Henrik Schachner
Posted 9 years ago

Henrik,

Thanks, I will play with it. In the meantime I give here a simpler illustration of the problem. Looks to me that ListPlot3D has deeper handicaps built in. Let's see this line:

Table[ListPlot3D[Table[i + j, {i, 1, k}, {j, 1, k}], PlotRange -> All,
   InterpolationOrder -> 0, ImageSize -> Medium, Mesh -> k - 1, 
  PlotLabel -> Table[i + j, {i, 1, k}, {j, 1, k}]], {k, 1, 8}]

As you can see ListPlot3D does not want to work with 1x1 arrays. Too bad. They are rightful members of the array family. Then it displays the 2x2 array as a 1x1 array although the 2x2 values are clearly there. The documentation regarding InterpolationOrder->0 clearly said: "InterpolationOrder->0 yields a collection of flat regions, with steps at each data point. " So "at each data point", in the case of the 2x2 array would mean a flat plane at 2, two flat planes at the 3s and a flat plane at 4, where 2,3,3,4 are the data points. ListPlot3D is not doing it. It leaves out the last row and the last column. Same thing for nxn arrays with n>=4. Then for the 3x3 array it does something really bizar as you can see, as if the two directions would not be equivalent. It suggests to me that ListPoint3D suffers from some kind of anizo-tropical sickness.

Attachments:
POSTED BY: Janos Lobb
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract