Что такое subplot в matlab
Что такое subplot в matlab
Create axes object in tiled positions
subplot divides the current figure into rectangular panes that are numbered rowwise. Each pane contains an axes object. Subsequent plots are output to the current pane.
plots income on the top half of the window and outgo on the bottom half. If the CurrentAxes is nested in a uipanel, the panel is used as the parent for the subplot instead of the current figure. The new axes object becomes the current axes.
subplot(m,n,p,’replace’) If the specified axes object already exists, delete it and create a new axes.
subplot(m,n,p,’align’) positions the individual axes so that the plot boxes align, but does not prevent the labels and ticks from overlapping.
subplot(h) makes the axes object with handle h current for subsequent plotting commands.
h = subplot(. ) returns the handle to the new axes object.
If a subplot specification causes a new axes object to overlap any existing axes, then subplot deletes the existing axes object and uicontrol objects. However, if the subplot specification exactly matches the position of an existing axes object, then the matching axes object is not deleted and it becomes the current axes.
subplot(1,1,1) or clf deletes all axes objects and returns to the default subplot(1,1,1) configuration.
You can omit the parentheses and specify subplot as
where m refers to the row, n refers to the column, and p specifies the pane.
To plot income in the top half of a figure and outgo in the bottom half,
The following illustration shows four subplot regions and indicates the command used to create each.
The following combinations produce asymmetrical arrangements of subplots.
You can also use the colon operator to specify multiple locations if they are in sequence.
Документация
Создайте оси в мозаичных положениях
Синтаксис
Описание
ax = subplot( ___ ) создает Axes объект, PolarAxes объект или GeographicAxes объект. Используйте ax сделать будущие модификации к осям.
subplot( ax ) делает оси заданными ax текущая система координат для родительской фигуры. Эта опция не заставляет родительский элемент изобразить текущую фигуру, если это уже не текущая фигура.
Примеры
Верхние и более низкие подграфики
Создайте фигуру с двумя сложенными подграфиками. Постройте синусоиду в каждом.
Квадрант подграфиков
Создайте фигуру, разделенную на четыре подграфика. Постройте синусоиду в каждом и заголовке каждый подграфик.
Подграфики с различными размерами
Создайте фигуру, содержащую с тремя подграфиками. Создайте два подграфика через верхнюю половину фигуры и третий подграфик, который охватывает более низкую половину фигуры. Добавьте заголовки на каждый подграфик.
Замена подграфика на пустые оси
Создайте фигуру с четырьмя диаграммами стебель-листья случайных данных. Затем замените второй подграфик на пустые оси.
Подграфики в пользовательских положениях
Создайте фигуру с двумя подграфиками, которые не выравниваются с положениями сетки. Задайте пользовательское положение для каждого подграфика.
Создание подграфиков с полярными осями
Создайте фигуру с двумя полярными осями. Создайте полярную линейную диаграмму в верхнем подграфике и полярной диаграмме поля точек в более низком подграфике.
Изменение Свойств осей графика после создания
Измените оси путем установки свойств Axes объекты. Измените размер шрифта для верхнего подграфика и ширину линии для более низкого подграфика. Некоторые функции построения графика устанавливают свойства осей. Выполните функции построения графика прежде, чем задать свойства осей постараться не заменять существующие настройки свойства осей. Используйте запись через точку, чтобы установить свойства.
Создание подграфика текущей системой координат
Преобразование существующих осей в подграфик
Создайте линейную диаграмму. Затем преобразуйте оси так, чтобы это был более низкий подграфик фигуры. Функция подграфика использует фигуру, на которой существовали исходные оси.
Преобразование осей в отдельных фигурах к подграфикам
Объедините оси, которые существуют на отдельных рисунках на одной фигуре с подграфиками.
Входные параметры
m — Количество строк сетки
1 (значение по умолчанию) | положительное целое число
Количество строк сетки в виде положительного целого числа.
Типы данных: single | double
n — Количество столбцов сетки
1 (значение по умолчанию) | положительное целое число
Количество столбцов сетки в виде положительного целого числа.
Типы данных: single | double
p — Положение сетки для новых осей
скаляр | вектор
Положение сетки для новых осей в виде скаляра или вектора из положительных целых чисел.
Пример: subplot(2,3,1) создает подграфик в положении 1.
Пример: subplot(2,3,[2,5]) создает подграфик, охватывающий положения 2 и 5.
Пример: subplot(2,3,[2,6]) создает подграфик, охватывающий положения 2, 3, 5, и 6.
Типы данных: single | double
pos — Пользовательское положение для новых осей
четырехэлементный вектор
left и bottom элементы задают положение нижнего левого угла подграфика относительно нижнего левого угла фигуры.
width и height элементы задают размерности подграфика.
Задайте значения между 0 и 1 это нормировано относительно внутренней части фигуры.
Примечание
При использовании скрипта, чтобы создать подграфики, MATLAB не завершает Position значение свойства до любого drawnow команда дается, или MATLAB возвращается, чтобы ждать пользовательской команды. Position значение свойства для подграфика подвержено изменениям до скрипта или обновляет график или выходы.
Пример: subplot(‘Position’,[0.1 0.1 0.45 0.45])
Типы данных: single | double
ax — Существующие оси, чтобы сделать текущим или преобразовать в подграфик
Axes возразите | PolarAxes возразите | GeographicAxes возразите | графический объект
Существующие оси, чтобы сделать текущим или преобразовать в подграфик в виде Axes объект, PolarAxes объект, GeographicAxes объект или графический объект с PositionConstraint свойство, такое как HeatmapChart объект.
Аргументы name-value
Пример: subplot(m,n,p,’XGrid’,’on’)
Некоторые функции построения графика заменяют настройки свойства. Рассмотрите свойства осей установки после графического вывода. Свойства, которые можно установить, зависят от типа осей:
Советы
Альтернативная функциональность
Используйте tiledlayout и nexttile функции, чтобы создать конфигурируемое плиточное размещение графиков. Параметры конфигурации включают:
Управление интервалом между графиками и вокруг ребер размещения
Опция для разделяемого заголовка наверху размещения
Опция, чтобы управлять, имеет ли плиточное размещение фиксированный размер или переменный размер, который может обратное течение
Для получения дополнительной информации смотрите Построение нескольких графиков.
subplot
Create axes in tiled positions
Syntax
Description
ax = subplot( ___ ) creates an Axes object, PolarAxes object, or GeographicAxes object. Use ax to make future modifications to the axes.
subplot( ax ) makes the axes specified by ax the current axes for the parent figure. This option does not make the parent figure the current figure if it is not already the current figure.
Examples
Upper and Lower Subplots
Create a figure with two stacked subplots. Plot a sine wave in each one.
Quadrant of Subplots
Create a figure divided into four subplots. Plot a sine wave in each one and title each subplot.
Subplots with Different Sizes
Create a figure containing with three subplots. Create two subplots across the upper half of the figure and a third subplot that spans the lower half of the figure. Add titles to each subplot.
Replace Subplot with Empty Axes
Create a figure with four stem plots of random data. Then replace the second subplot with empty axes.
Subplots at Custom Positions
Create a figure with two subplots that are not aligned with grid positions. Specify a custom position for each subplot.
Create Subplots with Polar Axes
Create a figure with two polar axes. Create a polar line chart in the upper subplot and a polar scatter chart in the lower subplot.
Modify Axes Properties After Creation
Modify the axes by setting properties of the Axes objects. Change the font size for the upper subplot and the line width for the lower subplot. Some plotting functions set axes properties. Execute plotting functions before specifying axes properties to avoid overriding existing axes property settings. Use dot notation to set properties.
Make Subplot the Current Axes
Convert Existing Axes to Subplot
Create a line chart. Then convert the axes so that it is the lower subplot of the figure. The subplot function uses the figure in which the original axes existed.
Convert Axes in Separate Figures to Subplots
Combine axes that exist in separate figures in a single figure with subplots.
Input Arguments
m — Number of grid rows
1 (default) | positive integer
Number of grid rows, specified as a positive integer.
Data Types: single | double
n — Number of grid columns
1 (default) | positive integer
Number of grid columns, specified as a positive integer.
Data Types: single | double
p — Grid position for new axes
scalar | vector
Grid position for the new axes, specified as a scalar or vector of positive integers.
Example: subplot(2,3,1) creates a subplot in position 1.
Example: subplot(2,3,[2,5]) creates a subplot spanning positions 2 and 5.
Example: subplot(2,3,[2,6]) creates a subplot spanning positions 2, 3, 5, and 6.
Data Types: single | double
pos — Custom position for new axes
four-element vector
The left and bottom elements specify the position of the bottom-left corner of the subplot in relation to the bottom-left corner of the figure.
The width and height elements specify the subplot dimensions.
Specify values between 0 and 1 that are normalized with respect to the interior of the figure.
Note
When using a script to create subplots, MATLAB does not finalize the Position property value until either a drawnow command is issued or MATLAB returns to await a user command. The Position property value for a subplot is subject to change until the script either refreshes the plot or exits.
Example: subplot(‘Position’,[0.1 0.1 0.45 0.45])
Data Types: single | double
ax — Existing axes to make current or convert to subplot
Axes object | PolarAxes object | GeographicAxes object | graphics object
Existing axes to make current or convert to a subplot, specified as an Axes object, a PolarAxes object, a GeographicAxes object, or a graphics object with an PositionConstraint property, such as a HeatmapChart object.
Name-Value Arguments
Example: subplot(m,n,p,’XGrid’,’on’)
Some plotting functions override property settings. Consider setting axes properties after plotting. The properties you can set depend on the type of axes:
Alternative Functionality
Use the tiledlayout and nexttile functions to create a configurable tiling of plots. The configuration options include:
Control over the spacing between the plots and around the edges of the layout
An option for a shared title at the top of the layout
Options for shared x— and y-axis labels
An option to control whether the tiling has a fixed size or variable size that can reflow
subplot
Create axes in tiled positions
Syntax
Description
ax = subplot( ___ ) creates an Axes object, PolarAxes object, or GeographicAxes object. Use ax to make future modifications to the axes.
subplot( ax ) makes the axes specified by ax the current axes for the parent figure. This option does not make the parent figure the current figure if it is not already the current figure.
Examples
Upper and Lower Subplots
Create a figure with two stacked subplots. Plot a sine wave in each one.
Quadrant of Subplots
Create a figure divided into four subplots. Plot a sine wave in each one and title each subplot.
Subplots with Different Sizes
Create a figure containing with three subplots. Create two subplots across the upper half of the figure and a third subplot that spans the lower half of the figure. Add titles to each subplot.
Replace Subplot with Empty Axes
Create a figure with four stem plots of random data. Then replace the second subplot with empty axes.
Subplots at Custom Positions
Create a figure with two subplots that are not aligned with grid positions. Specify a custom position for each subplot.
Create Subplots with Polar Axes
Create a figure with two polar axes. Create a polar line chart in the upper subplot and a polar scatter chart in the lower subplot.
Modify Axes Properties After Creation
Modify the axes by setting properties of the Axes objects. Change the font size for the upper subplot and the line width for the lower subplot. Some plotting functions set axes properties. Execute plotting functions before specifying axes properties to avoid overriding existing axes property settings. Use dot notation to set properties.
Make Subplot the Current Axes
Convert Existing Axes to Subplot
Create a line chart. Then convert the axes so that it is the lower subplot of the figure. The subplot function uses the figure in which the original axes existed.
Convert Axes in Separate Figures to Subplots
Combine axes that exist in separate figures in a single figure with subplots.
Input Arguments
m — Number of grid rows
1 (default) | positive integer
Number of grid rows, specified as a positive integer.
Data Types: single | double
n — Number of grid columns
1 (default) | positive integer
Number of grid columns, specified as a positive integer.
Data Types: single | double
p — Grid position for new axes
scalar | vector
Grid position for the new axes, specified as a scalar or vector of positive integers.
Example: subplot(2,3,1) creates a subplot in position 1.
Example: subplot(2,3,[2,5]) creates a subplot spanning positions 2 and 5.
Example: subplot(2,3,[2,6]) creates a subplot spanning positions 2, 3, 5, and 6.
Data Types: single | double
pos — Custom position for new axes
four-element vector
The left and bottom elements specify the position of the bottom-left corner of the subplot in relation to the bottom-left corner of the figure.
The width and height elements specify the subplot dimensions.
Specify values between 0 and 1 that are normalized with respect to the interior of the figure.
Note
When using a script to create subplots, MATLAB does not finalize the Position property value until either a drawnow command is issued or MATLAB returns to await a user command. The Position property value for a subplot is subject to change until the script either refreshes the plot or exits.
Example: subplot(‘Position’,[0.1 0.1 0.45 0.45])
Data Types: single | double
ax — Existing axes to make current or convert to subplot
Axes object | PolarAxes object | GeographicAxes object | graphics object
Existing axes to make current or convert to a subplot, specified as an Axes object, a PolarAxes object, a GeographicAxes object, or a graphics object with an PositionConstraint property, such as a HeatmapChart object.
Name-Value Arguments
Example: subplot(m,n,p,’XGrid’,’on’)
Some plotting functions override property settings. Consider setting axes properties after plotting. The properties you can set depend on the type of axes:
Alternative Functionality
Use the tiledlayout and nexttile functions to create a configurable tiling of plots. The configuration options include:
Control over the spacing between the plots and around the edges of the layout
An option for a shared title at the top of the layout
Options for shared x— and y-axis labels
An option to control whether the tiling has a fixed size or variable size that can reflow
subplot
Create axes in tiled positions
Syntax
Description
ax = subplot( ___ ) creates an Axes object, PolarAxes object, or GeographicAxes object. Use ax to make future modifications to the axes.
subplot( ax ) makes the axes specified by ax the current axes for the parent figure. This option does not make the parent figure the current figure if it is not already the current figure.
Examples
Upper and Lower Subplots
Create a figure with two stacked subplots. Plot a sine wave in each one.
Quadrant of Subplots
Create a figure divided into four subplots. Plot a sine wave in each one and title each subplot.
Subplots with Different Sizes
Create a figure containing with three subplots. Create two subplots across the upper half of the figure and a third subplot that spans the lower half of the figure. Add titles to each subplot.
Replace Subplot with Empty Axes
Create a figure with four stem plots of random data. Then replace the second subplot with empty axes.
Subplots at Custom Positions
Create a figure with two subplots that are not aligned with grid positions. Specify a custom position for each subplot.
Create Subplots with Polar Axes
Create a figure with two polar axes. Create a polar line chart in the upper subplot and a polar scatter chart in the lower subplot.
Modify Axes Properties After Creation
Modify the axes by setting properties of the Axes objects. Change the font size for the upper subplot and the line width for the lower subplot. Some plotting functions set axes properties. Execute plotting functions before specifying axes properties to avoid overriding existing axes property settings. Use dot notation to set properties.
Make Subplot the Current Axes
Convert Existing Axes to Subplot
Create a line chart. Then convert the axes so that it is the lower subplot of the figure. The subplot function uses the figure in which the original axes existed.
Convert Axes in Separate Figures to Subplots
Combine axes that exist in separate figures in a single figure with subplots.
Input Arguments
m — Number of grid rows
1 (default) | positive integer
Number of grid rows, specified as a positive integer.
Data Types: single | double
n — Number of grid columns
1 (default) | positive integer
Number of grid columns, specified as a positive integer.
Data Types: single | double
p — Grid position for new axes
scalar | vector
Grid position for the new axes, specified as a scalar or vector of positive integers.
Example: subplot(2,3,1) creates a subplot in position 1.
Example: subplot(2,3,[2,5]) creates a subplot spanning positions 2 and 5.
Example: subplot(2,3,[2,6]) creates a subplot spanning positions 2, 3, 5, and 6.
Data Types: single | double
pos — Custom position for new axes
four-element vector
The left and bottom elements specify the position of the bottom-left corner of the subplot in relation to the bottom-left corner of the figure.
The width and height elements specify the subplot dimensions.
Specify values between 0 and 1 that are normalized with respect to the interior of the figure.
Note
When using a script to create subplots, MATLAB does not finalize the Position property value until either a drawnow command is issued or MATLAB returns to await a user command. The Position property value for a subplot is subject to change until the script either refreshes the plot or exits.
Example: subplot(‘Position’,[0.1 0.1 0.45 0.45])
Data Types: single | double
ax — Existing axes to make current or convert to subplot
Axes object | PolarAxes object | GeographicAxes object | graphics object
Existing axes to make current or convert to a subplot, specified as an Axes object, a PolarAxes object, a GeographicAxes object, or a graphics object with an PositionConstraint property, such as a HeatmapChart object.
Name-Value Arguments
Example: subplot(m,n,p,’XGrid’,’on’)
Some plotting functions override property settings. Consider setting axes properties after plotting. The properties you can set depend on the type of axes:
Alternative Functionality
Use the tiledlayout and nexttile functions to create a configurable tiling of plots. The configuration options include:
Control over the spacing between the plots and around the edges of the layout
An option for a shared title at the top of the layout
Options for shared x— and y-axis labels
An option to control whether the tiling has a fixed size or variable size that can reflow