Overview
In this tutorial, we will learn about the Octave subplot command.
subplot command
The Octave subplot command is used to create a grid of plots on a single Figure window.
Syntax
subplot (rows, cols, index)
Set up a plot grid with rows x cols subwindows. We can specify the current slot for plotting by index.
Example
In this example, we will plot two plots in the same Figure using the subplot command.
The first plot is for the function:
y = x^2;
The second plot is for the function:
y= x^3;
Octave Script
% Subplot command Demo
% Octave Tutorials – www.TestingDocs.com
clf;
x = linspace(0,10,50);
y = x.^2;
subplot(1,2,1);
plot(x, y);
xlabel(“x”);
ylabel(“y”);
title(” y = x^2 Line Plot”);
y = x.^3;
subplot(1,2,2);
scatter(x, y);
xlabel(“x”);
ylabel(“y”);
title(” y = x^3 Scatter Plot”);
—
Octave Tutorials
Octave Tutorial on this website can be found at:
https://www.testingdocs.com/octave-tutorial/
More information on Octave can be found on the official website:
https://www.gnu.org/software/octave/index