2
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ So you basically want Ticks with names instead of numbers? $\endgroup$
    – Öskå
    Commented May 22, 2014 at 11:59
  • $\begingroup$ Exactly! Left numbers, bottom numbers, right countries $\endgroup$
    – eldo
    Commented May 22, 2014 at 12:01

1 Answer 1

6
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ Thanks, beautiful and exactly what I wanted :) $\endgroup$
    – eldo
    Commented May 22, 2014 at 12:06
  • $\begingroup$ I'm glad I could help :) $\endgroup$
    – Öskå
    Commented May 22, 2014 at 12:10

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.