MATLAB: Title position below the x axis

title subplot position

How can I change the position of a title from top of the figure to the below of x axis using code(automatically) on a subplot?

Best Answer

To change the position of the title, you can modify the Position property of the Title in the axes. You can modify the Position property of the Title object to get the desired results. Although, I would recommend first setting the Units property to normalized. In that way you can give Position values relative to the axes.
The Position argument requires 3 inputs, namely, the x,y and z coordinates. In normalized units, 0,0,0 is the left-bottom corner and 1,1,1 is the right-top corner of the axes. You can provide negative value to the y-coordinate in order to push the title below the axes.
plot([1 2 3], [1 2 3]); % Random plot
t = title('Random Plot', 'Units', 'normalized', 'Position', [0.5, -0.1, 0]); % Set Title with correct Position
Although, the example I have given is with the plot, the same applies to subplots as well.