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.
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.
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.
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.
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] .
Try modifying the TickLength property:
set(gca, 'Ticklength', [0 0])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With