How do I put more than one patternCustom plot into a figure when it seems like neither subplot or tiledlayout will work?
4 ビュー (過去 30 日間)
古いコメントを表示
I am using multiple patternCustom plots that use CoordinateSystem="polar", Slice="theta" that I would like to show in the same figure in a 2x3 format. It seems that neither tiledlayout or subplots will work. I would think there has to be a straightforward way to do this, that someone can show me.
2 件のコメント
Thorsten
2025 年 5 月 6 日
What goes wrong with tiledlayout or subplot? Without more information and without the function that you use for plotting it is hard to help.
採用された回答
Adam Danz
2025 年 5 月 6 日
編集済み: Adam Danz
2025 年 5 月 6 日
How do I put more than one patternCustom plot into a figure?
This is tricky because patternCustom does not have a parent argument. It plots to the current axes. The solution below uses subplot to create each axes and then immediately calls patternCustom so that it is plotted to the current axes.
Caveats
- If you're using uifigure, you must turn on the figure's HandleVisibility property so that the axes can be current.
- Tiledlayout cannot be used because patternCustom resizes the axes which is not permitted when using tiledlayout.
% Create data
h = helix;
[D,az,el] = pattern(h,2e9);
magE = D';
theta = 90-el;
phi = az';
thetaValues = 110:10:160;
fig = figure('color','w');
for i = 1:numel(thetaValues)
ax = subplot(2,3,i);
p = patternCustom(magE, theta, phi, CoordinateSystem="polar",Slice="theta", SliceValue=thetaValues(i));
% Optional property settings:
p.FontSize = 10;
p.LegendVisible = false;
title(ax, sprintf('Theta = %g', thetaValues(i)))
ax.Visible = 'on'; % To show title
ax.XAxis.Visible = 'off';
ax.YAxis.Visible = 'off';
end

Created in R2024b
4 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!