# How to Hide Axis in MATLAB

Ammar Ali Feb 02, 2024

This tutorial will introduce how to hide the axis ticks and labels from a plot using the `axis off` command and `set()` function in MATLAB.

## Hide the Axis Ticks and Labels From a Plot Using the `axis off` Command in MATLAB

If you want to hide both the axis ticks and the axis labels, you can use the `axis off` command, which hides all the axes. For example, let’s plot a sine wave and hide its axis ticks and labels using the `axis off` command. See the below code.

``````t = 1:0.01:2;
x = sin(2*pi*t);
y = cos(2*pi*t);
figure
plot(t,x)
xlabel('--time-->')
ylabel('--Amplitude-->')
axis off
``````

Output:

In the above figure, we can’t see any axis ticks and labels because of the `axis off` command, although you can see in the code labels are added to the plot.

## Hide the Axis Ticks and Labels From a Plot Using the `set()` Function in MATLAB

If you want to hide either the axis ticks or the axis labels, you can use the `set()` function in MATLAB. For example, let’s plot a sine wave and hide only its axis ticks using the `set()` function. See the below code.

``````t = 1:0.01:2;
x = sin(2*pi*t);
y = cos(2*pi*t);
figure
plot(t,x)
xlabel('--time-->')
ylabel('--Amplitude-->')
set(gca,'xtick',[],'ytick',[])
``````

Output:

In the above figure, we can’t see any axis ticks, but we can see the labels because we used the `set()` function to hide only the axis ticks, not the labels, but you can also hide the labels using this function.

Author: Ammar Ali

Hello! I am Ammar Ali, a programmer here to learn from experience, people, and docs, and create interesting and useful programming content. I mostly create content about Python, Matlab, and Microcontrollers like Arduino and PIC.