我有维数的三维矩阵,,D,N,。我想要创建一个动态热图来显示它在N上是如何变化的。这是我用来实现这一点的MATLAB代码。
for n=1:N
heatmap(dynamicCov(:,:,n));
pause(0.5);
end这段代码的问题是,对于每个n,它都会打开一个新的图形窗口。我希望在同一个热图窗口中更新它。有可能这样做吗?还有其他方法可以做到这一点吗?
谢谢。
发布于 2013-05-05 04:05:53
您需要使用HeatMap的非文档化的第二个输入,该输入指示是否应该创建一个绘图,还需要使用其他一些句柄技巧来获得创建的图形的句柄。有点像
data = rand(20,20,10); % create test data
hmo = HeatMap(data(:,:,1),false); % create but do not plot
plot(hmo); % do the plot
allHFig = findall(0,'Type','figure'); % get handle to all open figures
hFig = allHFig(1); % we want the most recently created figure
for idx = 2:size(data,3)
hmo = HeatMap(data(:,:,idx),false); % create heatmap but do not plot
plot(hmo,hFig); % plot to our existing figure
pause(0.5);
end发布于 2013-05-05 18:34:43
我找到了一种更好更简单的方法。它使用内置的imagesc()函数代替了生物信息学工具箱中的HeatMap()函数。守则如下:
dynamicCov = rand(20,20,10); % create test data
N = size(dynamicCov,3);
for n=1:N
imagesc(dynamicCov(:,:,n));
colormap('copper');
colorbar;
pause(0.5);
end参考资料:http://buli.waw.pl/matlab-heatmap-colormap/
https://stackoverflow.com/questions/16380581
复制相似问题