![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1138265/image.gif)
Ploting heatmaps in function of time
49 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Julien Maxime
am 27 Sep. 2022
Bearbeitet: Adam Danz
am 28 Sep. 2022
Hello,
I have search a solution for my problem but didn't find any that suited my problem.
Basically, I have a 3D matrix (18x17x2000) representing heatmap of a sample on the 2000 frames of the measurement. I would like to plot it all but with a slider or a cursor or whatever that could allow me to chose which frame I want to display, allowing me to easily go through my data.
I tried the VideoWriter tool but it gives really blurry and not convenient result. The goal is to keep the heatmap representation.
Thank you for your help,
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 27 Sep. 2022
Bearbeitet: Adam Danz
am 28 Sep. 2022
This demo produces a heatmap with random data and a slider that controls which slice of the 3rd dimension of data to plot.
Demo based on a similar solution for bar plots but uses a ValueChangingFcn to update the heatmap and title as the slider changes instead of a ValueChangedFcn which is evoked after making a change to the slider.
data = rand(20,20,2000); % data with size n*m*k
fig = uifigure();
uip = uipanel(fig,'Position', [20 100 500 300]);
heatObj = heatmap(uip, data(:,:,1));
title(heatObj, 'Frame #1');
n = size(data,3);
uis = uislider(fig,'Position',[50 50 450 3],...
'Value',1, ...
'Limits', [1,n], ...
'MajorTicks', [1, 200:200:n], ...
'MinorTicks', []);
uis.ValueChangingFcn = {@sliderChangingFcn, data, heatObj};
function sliderChangingFcn(~,event,data,heatObj)
% Update heatmap and title with new selection of data
value = round(event.Value);
heatObj.ColorData = data(:,:,value);
heatObj.Title = sprintf('Frame #%d',value);
end
Tip: set clim so the colorbar limits do not jump around as the heatmap data are updated. This is seen in the GIF below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1138265/image.gif)
7 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Colormaps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!