Ploting heatmaps in function of time

48 visualizzazioni (ultimi 30 giorni)
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,

Risposta accettata

Adam Danz
Adam Danz il 27 Set 2022
Modificato: Adam Danz il 28 Set 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.
  7 Commenti
Julien Maxime
Julien Maxime il 28 Set 2022
Thank you it is perfect!
Adam Danz
Adam Danz il 28 Set 2022
You may want to set clim so the colorbar limits do not jump around as you update heatmap. You can see this happening in the GIF I shared.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Distribution Plots in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by