In MATLAB, you can change the font size of text in figures using the `'FontSize'` property within the `xlabel`, `ylabel`, `title`, or `text` functions.
xlabel('X-Axis Label', 'FontSize', 12);
ylabel('Y-Axis Label', 'FontSize', 12);
title('Title', 'FontSize', 14);
Understanding Font Size in MATLAB
What is Font Size?
In MATLAB, font size refers to the scale or size of the text used in graphics such as axes labels, plot titles, legends, and annotations. Choosing the appropriate font size is crucial because it directly influences the readability and overall effectiveness of any visual presentation. Whether you are preparing a publication-quality figure or a simple plot for personal analysis, the font size must accommodate your audience's needs.
Default Font Sizes in MATLAB
MATLAB comes with default settings for font sizes in figures. These defaults may vary depending on your MATLAB version or system configuration. Understanding these defaults allows you to make informed decisions on adjustments, ensuring that your visualizations meet your communication goals effectively.

Changing Font Size for Different Plot Elements
Changing Axis Font Size
The axis labels are usually one of the first aspects to catch the attention of your viewer. Therefore, having a clear and appropriately sized axis label can enhance understanding. You can change the font size of the x-axis and y-axis labels using the `xlabel` and `ylabel` functions. For example:
x = 1:10;
y = rand(1,10);
plot(x, y);
xlabel('X-axis Label', 'FontSize', 14);
ylabel('Y-axis Label', 'FontSize', 14);
In this code snippet, both the x-axis and y-axis labels are set to a font size of 14, ensuring they are clear and easy to read.
Changing Title Font Size
The title of a plot should always be prominent enough to catch the viewer's eye. The `title` function in MATLAB allows you to adjust the title's font size easily. Here’s how you can do this:
title('Sample Plot', 'FontSize', 16);
Setting the title font size to 16 provides a good balance between visibility and aesthetics.
Changing Legend Font Size
Legends play a crucial role in distinguishing between data series plotted in a single graph. Therefore, ensuring that the text in legends is readable is essential. You can adjust the font size of the legend text using the `legend` function:
legend('Data Series 1', 'FontSize', 12);
This snippet sets the legend's font size to 12, allowing viewers to quickly understand the data being presented.
Changing Text Annotations Font Size
Text annotations are often used to highlight important points in your plots. You can customize these annotations using the `text` function, including specifying font sizes:
text(5,0.5,'Important Point', 'FontSize', 12);
Here, the annotation text will appear at the coordinates (5, 0.5) with a font size of 12, thus ensuring its visibility relative to other plot elements.

Setting Global Font Size
How to Set Global Font Size in MATLAB
If you want consistent font sizes across all elements in a figure, you can make adjustments globally using the `set(gca,'FontSize',...)` function. This approach is particularly useful when dealing with multiple plots. Here’s an example:
set(gca, 'FontSize', 14);
This command sets the font size for the current axes to 14, applying it to all axis labels, titles, and legends unless specifically overridden elsewhere.
Persistent Global Font Size Setting
To maintain your preferred global font size between MATLAB sessions, you can add the desired commands to a `startup.m` file. This method allows you to automatically set your specifications every time you start MATLAB. Simply include the same global setting command, and your configurations will load with each session, facilitating a more streamlined workflow.

Advanced Font Size Adjustments
Using `groot` for Font Size Control
MATLAB offers advanced functionalities through its `groot` command, which serves as a root graphics object. This command allows you to establish default properties for all axes in future figures. Here's how to set a default font size:
set(groot, 'DefaultAxesFontSize', 14);
By executing this command, all newly created figures will have axis font sizes set to 14, aligning with your preferences and ensuring consistency across visual outputs.
Font Size Customization for Exported Figures
When exporting figures for reports or presentations, ensuring that your font sizes are stable across formats is crucial. You can use the `saveas` function to save the figures while maintaining your specified font properties. For high-quality exports, consider using:
saveas(gcf, 'myplot.png');
print(gcf, 'myplot.pdf', '-dpdf', '-r300'); % for high quality
The `-r300` flag in the print command specifies a resolution of 300 DPI, guaranteeing that your fonts and graphics maintain their integrity in exported files.

Troubleshooting Common Font Size Issues
Font Size Not Reflecting Changes
If you find that font size changes are not reflecting in your figures, several issues could be at play. Check for possible conflicts with figure updates or existing settings that may override your adjustments. Sometimes, closing and reopening figures is necessary for changes to take effect.
Compatibility with Different MATLAB Versions
Different MATLAB versions may behave differently regarding font size functions. It’s worth noting that function syntax or defaults may change over time, so always refer to the official MATLAB documentation corresponding to your version. Staying updated with these changes can save you in troubleshooting efforts down the line.

Best Practices for Font Size in MATLAB
When selecting an appropriate font size, consider the context in which your visualization will be displayed. For academic presentations, it’s generally recommended to use larger font sizes (around 14-16 for titles and 12-14 for labels) for better visibility. For figures in reports, slightly smaller sizes may suffice, while ensuring clarity is always paramount. Additionally, maintaining a consistent format helps create professional visual outputs.

Conclusion
Choosing the right MATLAB font size is not just about aesthetics; it is a matter of effective communication. With the techniques discussed in this guide, you can customize font sizes across various elements in your plots, ensuring that your visualizations are both informative and accessible. Remember to experiment with different settings to find the perfect balance for your specific needs.

Additional Resources
For further reading and more in-depth understanding, please refer to MATLAB's official documentation on font handling, which provides comprehensive guidelines on formatting text in your visual outputs.

Call to Action
We encourage you to share your experiences or challenges with font size customization in MATLAB in the comments below. Don’t forget to share this article with fellow MATLAB users as well!