Ploting heatmaps in function of time
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
1 개 추천
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,
채택된 답변
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.

댓글 수: 8
Julien Maxime
2022년 9월 27일
It is exactly what I needed, thank you very much. Hoping this can help others with the same issue as mine.
Julien Maxime
2022년 9월 27일
I have another related question. Do you think it is possible to make the heatmap change as the cursors is moving and not only when the cursos is release ?
Adam Danz
2022년 9월 27일
Try replacing the valueChangedFcn with the valueChangingFcn.
Julien Maxime
2022년 9월 27일
편집: Torsten
2022년 9월 27일
Thank you very much for your help really. I dare ask one last question. Here is the relevant code part of the plot:
data = M;
fig = uifigure();
uip = uipanel(fig,'Position', [20 100 500 300]);
hh = heatmap(uip, data(:,:,1),'Colormap', hsv,'CellLabelColor', 'none','ColorLimits', [-360 50]);
title(hh, 'Electrode Fluorescence Heatmap - Frame #1');
n = size(data,3);
uis = uislider(fig,'Position',[50 50 450 3],...
'Value',1, ...
'Limits', [1,n], ...
'MajorTicks', 0:200:n, ...
'MinorTicks', []);
%valueChangedFcn for actualisation only when cursor is dropped
uis.ValueChangingFcn = {@sliderChangingFcn, uip, data};
function sliderChangingFcn(h,~,uip,data)
value = round(h.value);
hh = heatmap(uip,data(:,:,Value), 'Colormap', hsv, 'CellLabelColor', 'none', 'ColorLimits', [-360 50]);
title(hh, sprintf('Electrode Fluorescence Heatmap - Frame #%s',num2str(value)))
end
However, when i slide the cursor it changes the plot one time during the sliding but then stays and lag/block on this last plot. I have to drop it and move it again to diplay a new plot again. I found this guy who had a similar problem but I don't know how to adapt it to my situation: https://www.mathworks.com/matlabcentral/answers/521185-how-to-continuously-change-the-plotted-data-according-to-the-value-obtained-from-a-uislider-compon
Can you help me ?
Thank you very much.
Adam Danz
2022년 9월 27일
I've updated my answer to use a ValueChangingFcn. The updated answer also updates the existing heatmap rather than recreating it which is much more efficient.
Julien Maxime
2022년 9월 28일
Thank you it is perfect!
Patricia Darling
2025년 7월 29일
편집: Patricia Darling
2025년 7월 29일
Where would I embed clim in the code above. I tried making it stand alone in the main script and in the function and it doesn't seem to be impacting anything.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
