I am working on a project that takes arrays of data and visualizes them using ListDensityPlot. I noticed, when I imported an array from a CSV file, the last column was not being shown. On further inspection the last row also isn't. The array itself is of size X x Y, but when I try to plot using InterpolationOrder -> 0, it is dropping the last row and column, and plotting an array of dimensions (X-1) x (Y-1). This is changed, however, when I use InterpolationOrder -> 1 or remove the InterpolationOrder option from the arguments.

For an example, take the array {{1,2},{3,4}}. This gives two plots as shown below


As you can see, this first one is clearly not the plot I want, but even if it were, it is in the wrong format. This example shows that the interpolated ListDensityPlot is not treating the last row and column the same way as the non-interpolated. Is there a way to make a plot that behave nicely without having to drop the last row/column when using InterpolationOrder -> 0?


1 Answer 1


If you're using Interpolation -> 0, then I assume you want a step-like representation of the data. If that's the case, I would recommend either ArrayPlot or MatrixPlot.

For a 2x2 matrix, what you're seeing is the expected output of InterpolationOrder -> 0. If you try ListLinePlot[{1, 2}, InterpolationOrder -> 0], you can see that it produces an infinitely narrow discontinuity on the right side that is impossible to display in a density plot. This means that your density plot will always be of a size x-1 * y-1.

MatrixPlot[{{1, 2}, {3, 4}}/4]

Matrix plot of poster's data.

  • $\begingroup$ Thank you this is what I needed. $\endgroup$
    – Michael
    Aug 19, 2019 at 4:16

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.