필터 지우기
필터 지우기

Plotting Row and Columns

조회 수: 5 (최근 30일)
Cedric
Cedric 2022년 11월 14일
댓글: Cedric 2022년 11월 15일
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 ?

채택된 답변

Adam Danz
Adam Danz 2022년 11월 14일
편집: Adam Danz 2022년 11월 14일
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
Cedric
Cedric 2022년 11월 15일
Thank you for the detailed and clear answer.
Cedric

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by