Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have produced this MatrixPlot:

Rows refer to countries and columns to ranks. Row 1 refers to Norway with many 1 ranks, row 15 to Greece with many 15 ranks. Other countries are inbetween.

I would like to add a "Legend" to this plot, i.e. the string "Norway" should align (on the right side) with the first row etc.

I have no idea how to accomplish this and any help would be appreciated.

share|improve this question
So you basically want Ticks with names instead of numbers? – Öskå May 22 '14 at 11:59
Exactly! Left numbers, bottom numbers, right countries – eldo May 22 '14 at 12:01
up vote 5 down vote accepted

Specifying FrameTicks adds a "legend" to MatrixPlot's row:

legend = {"Hello", "How are you?", "Good Bye"};
MatrixPlot[{{1, 2, 1}, {3, 0, 1}, {0, 0, -1}}, 
  FrameTicks -> {
    {True (* Left *), 
     Thread[{Range@Length@legend, legend}](* Right *)}, 
    {True (* Bottom *), False (* Top *)}}]

Mathematica graphics

share|improve this answer
Thanks, beautiful and exactly what I wanted :) – eldo May 22 '14 at 12:06
I'm glad I could help :) – Öskå May 22 '14 at 12:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.