How to use linkaxes on two heatmaps in App Designer?
6 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone,
in App Designer I want to create an app that opens two measurement files and displays the data of each file in a heatmap. This works so far. Now I want to link both heatmaps so that when I zoom into one the other one zooms in as well. That's my attempt:
t = tiledlayout(app.Panel, 1, 2);
ax1 = nexttile(t);
heatmap1Hndl = heatmap(t, tbl1, x, y, "ColorVariable",z);
ax2 = nexttile(t);
heatmap2Hndl = heatmap(t, tbl2, x, y, "ColorVariable",z);
linkaxes([ax1 ax2]);
Doing that throws the error "Error using linkaxes. There must be at least one valid axes."
What am I doing wrong?
0 件のコメント
回答 (1 件)
Mario Malic
2024 年 8 月 28 日
編集済み: Mario Malic
2024 年 8 月 28 日
Hello,
The graphs can't be linked, since they are not axes object.
Here's a dirty approach, there are lots of assumptions, including that all heatmap charts have same X and Y labels. I am not sure if this fits your case, but you get the idea. You have to click on it first so it becomes the CurrentAxes, then use the scroll button to zoom in the charts,
T = readtable('outages.csv');
hFig = uifigure("WindowScrollWheelFcn", @ZoomHeatmap);
hTL = tiledlayout(2, 1, "Parent", hFig)
h1 = heatmap(hTL, T, 'Region','Cause');
nexttile(hTL)
h2 = heatmap(hTL, T, 'Region','Cause');
function ZoomHeatmap(src, event)
% Get layout, assuming only one exists
hLayout = findall(src, "type", "tiledlayout");
hHeatmaps = hLayout.Children;
% Obtain CurrentAxes from UIFigure and use its XLim and YLim property to assign
% to other objects
hCurrHeatmap = src.CurrentAxes;
hIdxFound = eq(hCurrHeatmap, hHeatmaps);
% Update properties
hHeatmaps(~hIdxFound).XLimits = hCurrHeatmap.XLimits;
hHeatmaps(~hIdxFound).YLimits = hCurrHeatmap.YLimits;
end
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!