How do I put more than one patternCustom plot into a figure when it seems like neither subplot or tiledlayout will work?

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

What goes wrong with tiledlayout or subplot? Without more information and without the function that you use for plotting it is hard to help.
figure;
tiledlayout(2,3);
nexttile;
A = patternCustom( magE_H1 , theta_H1, phi_H1, CoordinateSystem="polar", Slice="theta", SliceValue=[100]);
nexttile;
B = patternCustom( magE_V1 , theta_V1, phi_V1, CoordinateSystem="polar", Slice="theta", SliceValue=[100]);
nexttile;
C = patternCustom( magE_H2 , theta_H2, phi_H2, CoordinateSystem="polar", Slice="theta", SliceValue=[100]);
nexttile;
D = patternCustom( magE_V2 , theta_V2, phi_V2, CoordinateSystem="polar", Slice="theta", SliceValue=[100]);
nexttile;
E = patternCustom( magE_H3 , theta_H3, phi_H3, CoordinateSystem="polar", Slice="theta", SliceValue=[100]);
nexttile;
F = patternCustom( magE_V3 , theta_V3, phi_V3, CoordinateSystem="polar", Slice="theta", SliceValue=[100]);
The above is an example of the plotting scheme I am trying. When I run it, it plots A in the correct position, then when it gets to the following nexttile, it overwrites it with a blank X and Y axis, then that is overwritten by a single plot of B, and so on... until finally, I just have a single plot of F showing.

댓글을 달려면 로그인하십시오.

 채택된 답변

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

That's fantastic! Thanks for your help!
Will this also work if each plot maintains the same theta but uses different data for magE, theta, and phi (comparing different antennas)?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2022a

질문:

2025년 5월 6일

댓글:

2025년 5월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by