MATLAB Answers

Subplot in Matlab Appdesigner

조회 수: 10(최근 30일)
Abdul Mumin Redhowan
Abdul Mumin Redhowan 2021년 7월 19일
답변: Cris LaPierre 2021년 7월 20일
Unfortunately I have gone through mane documentations and question answers but I coudn't find a clear soulution of subplot in matlab app designer. I want to plot this in -- app.UIAxes2
Please help me with this. I am giving my code down below.
subplot(311);
plot(days,cral,days,crbl,'--');
title('Effective contact/transmission rate');
legend('After lockdown', 'Before Lockdown');
subplot(313);
plot(days,TNI,days,TNIwl,'--');
title('Comparison of Total infecteds');
legend('Lockdown', 'Without Lockdown');
subplot(312);
plot(days,I,days,Iwl,'--');
title('Comparison of I');
legend('Lockdown', 'Without Lockdown');
The graph I get from matlab is given below

답변(1개)

Cris LaPierre
Cris LaPierre 2021년 7월 20일
See the page Display Graphics in App Designer. The relevant section is Create Tile Chart Layout.
The specific text that applies is as follows:
For example, the subplot function does not support automatic resizing. To use this function in your app:
  1. Drag a panel component from the Component Library onto your canvas.
  2. Set the AutoResizeChildren property of the panel to 'off'.
  3. Specify the panel as the parent container using the 'Parent' name-value argument when you call subplot. Also, specify an output argument to store the axes.
  4. Call the plotting function with the axes as the first input argument.
app.Panel.AutoResizeChildren = 'off';
ax1 = subplot(1,2,1,'Parent',app.Panel);
ax2 = subplot(1,2,2,'Parent',app.Panel);
plot(ax1,[1 2 3 4])
plot(ax2,[10 9 4 7])

Community Treasure Hunt

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

Start Hunting!

Translated by