Plotting Row and Columns

9 Ansichten (letzte 30 Tage)
Cedric
Cedric am 14 Nov. 2022
Kommentiert: Cedric am 15 Nov. 2022
NOTE run the data extraction file first then the data processing one
In the attached code I would want it to produces each figures with an arrangement of 5 rows and 2 columns. When the code runs it does make a 5 ROWS And 2 columns when the figure size is normal. But when the figure window is maximized it does not. I would want the code to still produce 5 rows and 2 columns of plots when thefigure window is maximized.
Any sugggestions ?

Akzeptierte Antwort

Adam Danz
Adam Danz am 14 Nov. 2022
Bearbeitet: Adam Danz am 14 Nov. 2022
There are important items to address here.
1. Creating new figures
if mod(n,10) == 0 %checks whether Remainder after division of the year number is returns to zero, if yes a new figure window will open for the new decade
figure('WindowState','maximized');
end
This section of your code creates a new figure every 10 iterations of your for-loop and then new axis tiles are added to the new figure. If you remove this, then all axis tiles will be added to the same figure resuling in all 50 axes added to the same figure.
If your goal is to merely use the default figure size, then change this to
if mod(n,10) == 0 %checks whether Remainder after division of the year number is returns to zero, if yes a new figure window will open for the new decade
figure();
end
2. Flow layout
You aren't specifying the intended layout of your axes. You mention that there is a 5x2 layout but if you make the figure very narrow then the tiles will refactor into a 10x1 layout. If you want a specific 5x2 layout, specify the grid size by calling this after creating the figure
tiledlayout(5,2)
but if you'd rather keep the flow arrangement, then you can use the line below. Just know that the layout might not be 5x2 - it will depend on the figure size, among other factors.
See tiledlayout for more info on flow arrangement.
tiledlayout('flow')
3. How nexttile works
nexttile addes a new tile (axes) to a tiledChartLayout which is the object created by tiledlayout. It's recommended to explicitly define the tiledlayout using one of the lines above so that people reading your code (including your future self) can more easily identify what is going on. If you call nexttile without defining a tiledChartLayout, then it the layout will default to flow.
  1 Kommentar
Cedric
Cedric am 15 Nov. 2022
Thank you for the detailed and clear answer.
Cedric

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by