# Solved: font size axis

The occurrence of a font sizing problem within the axis of a plot is wholly a frequent issue among Matlab users. But worry not, because Matlab, being a versatile computational software, provides a wide array of selections when it comes to handling font sizes on the plot axis.

In Matlab, default settings can sometimes limit the expression of our data presentation. The good news is, with appropriate understanding and command utilization, you can easily set the font size of the axis to your desired value.

## Solution to Font Size Issue on the Axis in Matlab

To solve this problem, the set() function is the most efficient tool in Matlab. This function makes changes in properties, such as font size, to graphic objects like axis labels.

To ensure the illustration of this, consider the example of creating a plot and setting the font size to 14.

```x = 1:10;
y = randn(1,10);
plot(x,y)
set(gca, 'FontSize', 14)
```

The function ‘gca’ (get current axis) accesses the current axis on the current figure. Using ‘set(gca, ‘FontSize’, 14)’, you can set the font size for the x-axis, y-axis, and tick labels to 14.

## Step-by-step Explanation of the Code

The in-deep looking of this particular example makes the ideal opportunity for us to dissect how the Matlab code operates.

The code launches, and Matlab will initialize variables x and y which will be plotted against each other. x is a vector containing elements from 1 to 10 while y is a vector of 10 random numbers.

Here’s the breakdown:

1. x = 1:10; This line of code creates a row vector, x, from 1 to 10.
2. y = randn(1,10); This line creates another row vector, y, with random numbers.
3. plot(x,y); This function generates the plot for x against y.
4. set(gca, ‘FontSize’, 14); Here, we set the current axis’ FontSize property to 14.

The final line, set(gca, ‘FontSize’, 14), indeed holds the key. The ‘set’ command extends us the ability to modify the properties by utilizing ‘FontSize’. ‘gca’ (get current axis) permits us to address the axis of the current figure. Hence, ‘set(gca, ‘FontSize’, 14)’ changes the font size of your x-axis, y-axis, and tick labels to 14.

## Other Useful Matlab Functions to Adjust Axis Appearance

Besides the set() function, Matlab has other beneficial functions that allow us to adjust the axis appearance:

• xlabel(‘Name’) and ylabel(‘Name’): These functions add labels to the x-axis and y-axis respectively.