Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove xticks but keep xticklabels in MATLAB

Tags:

plot

matlab

I have a plot in MATLAB from which I would like to remove the xticks but keep the xticklabels. If I just remove the xtick like so:

set(gca, 'XTick', []);

...then the labels also disappear. Is there a way to keep the labels, without having to manually recreate them with text boxes? I thought about trying to make the length of the xticks zero, but this answer suggests that xtick properties cannot be independently controlled.

like image 842
Bill Cheatham Avatar asked Mar 20 '13 16:03

Bill Cheatham


People also ask

How do I get rid of Xticks in Matlab?

Direct link to this answerTickLength = [0 0]; This will allow you to keep the labels but remove the tick marks on only the x-axis.

How do you turn off axis labels 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.

What does Xticks do in Matlab?

xticks( ticks ) sets the x-axis tick values, which are the locations along the x-axis where the tick marks appear. Specify ticks as a vector of increasing values; for example, [0 2 4 6] . This command affects the current axes.

How do I restrict an AXE in Matlab?

Change Axis LimitsCreate a line plot. Specify the axis limits using the xlim and ylim functions. For 3-D plots, use the zlim function. Pass the functions a two-element vector of the form [min max] .


1 Answers

Try modifying the TickLength property:

set(gca, 'Ticklength', [0 0])
like image 189
Eitan T Avatar answered Sep 29 '22 11:09

Eitan T