MATLAB Hide Axis

  1. Hide the Axis Ticks and Labels From a Plot Using the axis off Command in MATLAB
  2. Hide the Axis Ticks and Labels From a Plot Using the set() Function in MATLAB

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.

clc
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:

Hide Axis using axis Command in matlab

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.

clc
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:

hide axis ticks using the set() function in matlab

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.

Contribute
DelftStack is a collective effort contributed by software geeks like you. If you like the article and would like to contribute to DelftStack by writing paid articles, you can check the write for us page.

Related Article - MATLAB Plot

  • MATLAB Animated Plot
  • MATLAB RGB Triplet