How can one display multiple Heatmaps in one figure on the same scale?
34 次查看(过去 30 天)
显示 更早的评论
Hello,
I have spectral data from three components for several events. I have a short routine to plot the spectra:
% heater1
% Get the spectra and frequencies
spectra = Calc_All;
freeks = 1:size(spectra,2);
% Pick events
picked_events = ident(selections_from_table);
%Choose the event labels to use (e.g., file_name)
event_labels = input_struc.file_name(picked_events);
The
figure('Name','Spectral Map','NumberTitle','off','MenuBar','none','ToolBar','none');
for compo = 1:3
subplot(1,3,compo)
this_spec = squeeze(spectra(compo,:,:));
hdl = heatmap(freeks,event_labels,this_spec');
end
If I plot this just as it is, I get the following:
where (I guess it's hard to see) the max levels on each one are different, and so is the shading.
I don't know if fixing a Ylim for each one will work, since that's not known beforehand. Is there a simple way around this? I didn't see an "Answer" here. heatmap() is quite involved!
Thanks!
Doug
0 个评论
采纳的回答
Voss
2022-5-20
You can specify the ColorLimits of all three heatmaps after they are created.
Here's a demonstration with some random data:
for compo = 1:3
subplot(1,3,compo)
% 1st heatmap ranges between 1 and 2, 2nd is [2 3], 3rd is [3 4]
% in order to see the effect of using common ColorLimits
this_spec = compo+rand(5,10);
hdl(compo) = heatmap(1:5,1:10,this_spec');
end
if numel(hdl) > 1
c_lim = get(hdl,'ColorLimits');
c_lim = vertcat(c_lim{:});
c_lim = [min(c_lim(:,1)) max(c_lim(:,2))];
set(hdl,'ColorLimits',c_lim);
end
7 个评论
Voss
2022-5-21
You're welcome!
By the way, here's the documentation for changing properties of heatmaps:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!