Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 at 11:59
    
Exactly! Left numbers, bottom numbers, right countries –  eldo May 22 at 12:01

1 Answer 1

up vote 4 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 at 12:06
    
I'm glad I could help :) –  Öskå May 22 at 12:10

Your Answer

 
discard

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.