Ask Your Question

MatrixPlots with cell entries

asked 2018-02-22 11:19:50 -0500

jepstra gravatar image

Is there a nice way to combine MatrixPlot with something else to have a label in each cell such as in this picture?

image description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-02-26 15:38:41 -0500

j.c. gravatar image

updated 2018-02-26 15:43:01 -0500

Something like this works:

# make some random matrix
A = random_matrix(ZZ,7,7)
# make a graphics object consisting of the values of A
g = sum([text(str(A[j,k]),(j,k)) for j in range(7) for k in range(7)])
# matrix plot A and then combine with the text
h = g2+g
#  for some reason the graphics window resizes to the shape of the added text graphics
# regardless of whether h = g + g2 or h = g2 + g
h.SHOW_OPTIONS['xmax'] = 6.5
h.SHOW_OPTIONS['xmin'] = -.5
h.SHOW_OPTIONS['ymax'] = 6.5
h.SHOW_OPTIONS['ymin'] = -.5
# show result

Image here: (I don't have enough points to embed it).

edit flag offensive delete link more


@j.c. excellent, really!

jepstra gravatar imagejepstra ( 2018-02-27 04:03:59 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-02-22 11:19:50 -0500

Seen: 36 times

Last updated: Feb 26