# Is there a similar plotting feature supported in Mathematica?

I write following program in Python to plot from array:

import matplotlib.pyplot as pyplot
import numpy

p = 5
n = 25
s = numpy.zeros([n,n])

s[0, 0] = 1
for i in range(0, n):
for j in range(0, i+1):
s[i, j] = i+j

pyplot.imshow(s)
pyplot.show()


to get following image.

I would like to imitate such plotting style of image (grid type and each mesh has color corresponds to its array value) in Mathematica, too. How to implement this in Mathematica? I found ListDensityPlot, but it seems not what I want. Anyway, if such function exists, I hope its input is 2D-List(or array).

Apologize that my question is not detailed, since I don't know much about Mathematica. If it's duplicate, please let me know.

• How about ArrayPlot and MatrixPlot? – Henrik Schumacher Apr 8 at 6:09
• @HenrikSchumacher Thanks a lot that's exactly what I want. – ChoMedit Apr 8 at 6:14
• You're welcome! – Henrik Schumacher Apr 8 at 6:21

There are a few ways to get what you want. One way to get close would be:

ArrayPlot[
PadRight[Table[i + j, {i, n}, {j, i}], {n, n}],
ColorFunction -> "BlueGreenYellow",
FrameStyle -> Black,
FrameTicks -> {{True, False}, {True, False}},

If you delve deeper into the various options, it's not too difficult to replicate exactly the figure you show. One thing to note is that Mathematica indexes arrays/lists/vectors/matrices from 1 rather than 0. If you want to start from 0, you'll need to take a look at the DataRange option, or else specify the coordinates as a list {{0, 0, 1}, {0, 1, 1}, ...} etc.