問題描述
Як прызначыць індывідуальныя пазнакі значэнняў на восях у Matlab? (How to assign individual labels to values on the axes in Matlab?)
I have a matrix in matlab. Each row/column has a unique label. these labels are in a row‑matrix. How do I print these labels on the figure next to that row/column number? Nevermind the cluminess in display, I want to see the labels against the rows rather than the row numbers.
‑‑‑‑‑
參考解法
方法 1:
If I understand your problem correctly, you have a plot like
pcolor(magic(4));
and labels similar to
lbl = ['a'; 'b'; 'c'; 'd'];
Following my example you have four labels for both X and/or Y. All you need to do from here is set the XTicks of your axes to the number of lables you have, then set the XTickLabels like so:
set(gca,'XTick',1:length(lbl),'XTickLabel',lbl)
(by stackoverflow、Geodesic)