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.

Possible Duplicate:
Labelling ArrayPlot Charts

I am making a MatrixPlot. For example, consider the following:

list = {{1, 1, 0, 1}, {0, 0, 1, 1}, {1, 0, 1, 0}};
MatrixPlot[list]

which yields:

MatrixPlot

But now suppose I want to label the axes with other numbers. For example, I would like to label the ticks on the horizontal axis as 101, 167, 188, 205 (as they are not now), and the ticks on the vertical axis as 1, 2, 3 (as they already are). I know this is a strange request, but it is because I would like to label the horizontal axis according to "particle number" (which is an integer in my application).

Or maybe a better way to phrase the question is, is it possible to label axis/frame ticks with any arbitrary string (for example, labeling the horizontal axis with "Alice", "Bob", "Carla", and "David")? One possibility seems like FrameTicks, but I can't seem to figure out if it can be used to map strings.

If I use

list = {{1, 1, 0, 1}, {0, 0, 1, 1}, {1, 0, 1, 0}};
MatrixPlot[list, 
 FrameTicks -> {{{1, 2, 3}, None}, {{101, 167, 188, 205}, None}}]

I get:

MatrixPlot

because, of course, FrameTicks thinks I'm referring to which discrete values to label.

Also, if I try:

list = {{1, 1, 0, 1}, {0, 0, 1, 1}, {1, 0, 1, 0}};
MatrixPlot[list, 
 FrameTicks -> {{{1, 2, 3}, None}, {{"101", "167", "188", "205"}, 
    None}}]

I get "Not a valid tick specification."

Do you have any other ideas?

share|improve this question

marked as duplicate by rm -rf, Mr.Wizard Jun 9 '12 at 3:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
I believe this was covered in mathematica.stackexchange.com/questions/6043/…. –  David Carraher Jun 8 '12 at 16:11
1  
This doesn't work because the frame ticks specification needs positions to determine where to place the labels. If you use numbers mma assumes positions == labels, and with the high values you're using they are out of the plot range. In the case of the strings as labels there is no position information at all. –  Sjoerd C. de Vries Jun 8 '12 at 17:39
1  
This question is about something qualitatively different than the above-referenced question. FDSg's answer below is correct, and this should not be marked as a duplicate. –  Steven Bedrick Nov 6 '13 at 0:19
add comment

1 Answer 1

up vote 8 down vote accepted

try this

 MatrixPlot[list,  
 FrameTicks -> {
 {{1, 2, 3}, None}, {{{1, 101}, {2, 167}, {3, 188}, {4, 205}}, {{1, "Alice"}, {2,"Bob"}}}
 }]

enter image description here

share|improve this answer
add comment

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