what is subplot and how to use it?
古いコメントを表示
i want to plot two graphs in one single window then how to do so? what is block? also give some hint on how join various elements and blocks while using simulink?
採用された回答
その他の回答 (2 件)
Benjamin Kraus
2023 年 10 月 30 日
編集済み: Benjamin Kraus
2024 年 7 月 2 日
If you are using MATLAB R2019b or later, you should consider using tiledlayout and nexttile instead of subplot. tiledlayout and nexttile supports most of the features of subplot, and many more, and you should see better performance with tiledlayout and nexttile.
The tile layout is the same as subplot, but tiledlayout also supports a "flow" layout that will automatically adjust the number of rows and columns to optimally fit your axes. In addition, since MATLAB R2023a you can specify a "vertical" or "horizontal" layout that will stack your axes vertically or horizontally.
The equivalent to subplot(3, 4, plotNumber); with tiledlayout would be this:
tiledlayout(3,4)
nexttile(plotNumber)
2 件のコメント
Sagnik
2024 年 7 月 2 日
minor typo .. it should be nexttile (not nextile)
Benjamin Kraus
2024 年 7 月 2 日
@Sagnik: Thanks. I've fixed it.
Matt Fig
2012 年 10 月 5 日
figure
subplot(1,2,1)
plot(1:10)
subplot(1,2,2)
plot((1:10).^2)
help subplot
5 件のコメント
monali
2012 年 10 月 7 日
Prabin Rath
2018 年 6 月 7 日
1 to 10 with a spacing of 1. Like 1,2,3,4....
Olivier GARRIGUES
2023 年 10 月 6 日
Its the number of the plot, from top to bottom and left to right. So if you have a 1 by 2 plot, subplot(1,2,1) is the left one and subplot(1,2,2) the right one.
Image Analyst
2023 年 10 月 6 日
@Asim the first two numbers are the number of rows and columns in the layout of all the plots in a grid. The third number is the "number" of the particular single plot that is in the grid. For example if you have 3 rows and 4 columns, this chart gives the third number:
1 2 3 4
5 6 7 8
9 10 11 12
So for example if you wanted to make a plot in the second row and third column, that would be #7, so you'd do this
subplot(3, 4, 7)
and if you wanted to plot something in the third row, second column, that would be #10 and you'd call this before you called plot:
subplot(3, 4, 10);
Does that explain it better?
カテゴリ
ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!