MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   在MATLAB中将图像绘制为轴标签 (https://www.labfans.com/bbs/showthread.php?t=26250)

poster 2019-12-14 20:13

在MATLAB中将图像绘制为轴标签
 
我正在使用imagesc命令在MATLAB中绘制7x7像素的``图像'':

imagesc(conf_matrix, [0 1]); 这代表了七个不同对象之间的[URL="http://en.wikipedia.org/wiki/Confusion_matrix"]混淆矩阵[/URL] 。我有七个对象的缩略图,我想用作轴刻度标签。是否有捷径可寻?



[B]回答:[/B]

我不知道一个[I]简单的[/I]方法。确定标签的轴属性XtickLabel只能是字符串。

如果您想要一种不太容易的方法,则可以本着以下不完整(就不完整解决方案而言)代码的精神进行操作,创建一个标签:

h = imagesc(rand(7,7)); axh = gca; figh = gcf; xticks = get(gca,'xtick'); yticks = get(gca,'ytick'); set(gca,'XTickLabel',''); set(gca,'YTickLabel',''); pos = get(axh,'position'); % position of current axes in parent figure pic = imread('coins.png'); x = pos(1); y = pos(2); dlta = (pos(3)-pos(1)) / length(xticks); % square size in units of parant figure % create image label lblAx = axes('parent',figh,'position',[x+dlta/4,y-dlta/2,dlta/2,dlta/2]); imagesc(pic,'parent',lblAx) axis(lblAx,'off') 一个问题是标签将具有与原始图像相同的颜色图。



[url=https://stackoverflow.com/questions/4850002]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:17

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.