Reputation: 241
I am trying to plot a heat map using pcolor
which is working fine, but both the x-axis ticks are just increasing integers labelling each data point.
Is there a way I can plot so that one of the axes uses a cell array as its ticks?
For example, at the moment I have data like:
x = [1, 2, 3]
y = {'a', 'b', 'c'}
z = [4, 2, 6; 5, 3, 1; 6, 4, 5]
Then pcolor(x,y,z)
would throw an error saying the data inputs must be real.
pcolor(z)
would work, but tick both axes 1 2 3
Any ideas?
Upvotes: 2
Views: 489
Reputation: 1358
x
, y
and z
are supposed to contain your data, not the tick labels. You can change the tick labels of any plot by setting the XTickLabel
and/or YTickLabel
property of the axes:
x = 1:3;
y = 1:3;
z = rand(3);
pcolor(x,y,z);
set(gca,'XTick',1:3);
set(gca,'XTickLabel',{'a','b','c'});
Result:
Upvotes: 4