0
$\begingroup$

I was using ListPlot3D and noticed that it wasn't plotting the last elements of my two dimensional list. (i.e. My 5x10 matrix was only showing a 4x9 set of data). However, when I use just an arrayplot it works beautifully. A Simple set of data I used is below:

    Temp = Table[0, {10}, {5}];
    Temp[[1, 3]] = 10;
    Temp[[2, 2 ;; 4]] = 10;
    Temp[[3 ;; 8, All]] = 10;
    Temp[[9, 2 ;; 4]] = 10;
    Temp[[10, 3]] = 10;

    ArrayPlot[Temp]

Sample Array Plot

    ListPlot3D[Temp, InterpolationOrder -> 0, Mesh -> None]

3D Image

When I use the 3D plot, only one point on the diamond show up and the far right side is missing. I specifically want InterpolationOrder = 0, because for my case I want it to be essentially a 3DArray plot.

$\endgroup$
  • 3
    $\begingroup$ That's the correct behaviour. ListPlot3D draws a surface connecting points. InterpolationOrder -> 0 means it interpolates between points with a flat, horizontal surface. You have $5\times 10$ points, so you have $4\times 9$ intervals between the points, so you have also $4\times 9$ surfaces interpolating between the points. This thread might give you ideas on how to proceed to obtain the desired result. $\endgroup$ – corey979 Nov 28 '16 at 23:26
  • $\begingroup$ Ah, I see. I was under the impression it would plot each point and just give it a volume of sorts! I appreciate the explanation! $\endgroup$ – Pfab Nov 28 '16 at 23:43
  • $\begingroup$ Related Q/As: Height-dependent filling color in 3D Data Plots and How can I imitate the style of a certain 3D bar chart? $\endgroup$ – kglr Nov 29 '16 at 0:12
3
$\begingroup$

For the requirement

I want it to be essentially a 3DArray plot.

you can use DiscretePlot3D using your Temp to define a function foo:

ClearAll[foo];
(foo[##2] = #) & @@@ (Join @@ MapIndexed[Flatten@{##} &, Temp, {2}]);


DiscretePlot3D[foo[t, u], {t, 1, 10}, {u, 1, 5}, ExtentSize -> Full, 
 BoxRatios -> {1, 1/2, 1}]

Mathematica graphics

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