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.
我在matlab中有一个矩阵。每行/每列都有一个唯一的标签。这些标签是行矩阵。如何在该行/列号旁边的图上打印这些标签?没关系显示的笨拙,我想看到行的标签而不是行号。
1 个解决方案
#1
2
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:
按照我的例子,你有四个X和/或Y标签。你需要做的就是将你的轴的XTicks设置为你拥有的标签数量,然后像这样设置XTickLabels:
set(gca,'XTick',1:length(lbl),'XTickLabel',lbl)
#1
2
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:
按照我的例子,你有四个X和/或Y标签。你需要做的就是将你的轴的XTicks设置为你拥有的标签数量,然后像这样设置XTickLabels:
set(gca,'XTick',1:length(lbl),'XTickLabel',lbl)