

Set( a3, 'fontsize', 16 ) Font sizes increase from left to right. This concept extends to all other plot axes properties and shows how each sub-plot can be fully customized.
#Matlab subplot label code#
The code snippet below is an example where the font is being set to a different size on each axes. For example, if we wanted to change the font size, we would have to specify the font size on each axes. This is important because now that there are multiple plot axes on the figure, we will need to specify which axes we are referencing whenever we change properties. Notice in the code for this example that I have saved the axes handle (a1, a2, a3) for each of the subplots. Text( 0.5, 0.5, '3', 'fontsize', 48 ) Simple example plot with three columns. For convenience, I have also used the text() function to display the linear index in each subplot. Let’s start with a simple example that includes three sub-plots along a single row. It’s OK if this doesn’t make sense yet, the ordering is visualized in all of the examples within this section, especially in the grid example.

The index starts at 1 and increases from left to right and top to bottom. The third argument is a linear index that selects the current active plot axes. The first two arguments define the number of rows and columns that will be included in the grid. The basic form of the subplot() command takes in three inputs: nRows, nCols, linearIndex. The subplot() function in MATLAB/Octave allows you to insert multiple plots on a grid within a single figure. The source code for the included examples can be found in the Git H ub repository.

The provided examples should work in both MATLAB and Octave. In this tutorial, I describe three different ways to use the subplot() command and provide examples of each. They can also be used to quickly create interactive Graphical User Interfaces (GUIs). They allow users to very quickly create customized data visualizations and displays. Sub-plotting is a very powerful feature in MATLAB.
