Subplot in Matlab Appdesigner

137 views (last 30 days)
Abdul Mumin Redhowan
Abdul Mumin Redhowan on 19 Jul 2021
Answered: Cris LaPierre on 20 Jul 2021
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

Answers (1)

Cris LaPierre
Cris LaPierre on 20 Jul 2021
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])

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!