How to modify tick labels on MATLAB plot

Post date: Nov 10, 2012 8:16:17 PM

Problem: How to replace the numerical tick label into text?

The figures below show the original figure (left), and the modified one (right).

Example:

clear; clc; close all;  data_matrix = randn(9,5); row_name = {'Batman','Spiderman','Hulk'}; col_name = {'Monday','Tuesday','Wednesday','Thursday','Friday'};  figure;  subplot(1,2,1); imagesc(data_matrix); title('Movies vs days'); % ------ subplot(1,2,2); imagesc(data_matrix); title('Movies vs days'); set(gca,'XTick',[1:5]) set(gca,'XTickLabel',col_name) set(gca,'YTick',[2:3:9]) set(gca,'yTickLabel',row_name) 

Good resources can be found below:

http://www.mathworks.com/support/solutions/en/data/1-15HXQ/

if you need to rotate the tick label by arbitrary degree, see this:

http://www.mathworks.com/support/solutions/en/data/1-15TK6/index.html?solution=1-15TK6