In Matlab figure, I would like to remove ticks only from the top and right axes with keeping the plot box on.
I know if I make the plot box off, the ticks on the top and right go away. But, this is not what I want. In other words, I want to keep ticks only at the bottom and left and, at the same time, want to keep the plot box on.
TickLength = [0 0]; This will allow you to keep the labels but remove the tick marks on only the x-axis.
You have to resort to trickery. If you are trying to get two axes on one another with linked x-axis and two separate y-axes on both sides, the easiest approach is to set both axes to box off . Then move x-axe of second axes to the top, remove tick and axis labels and it will nicely close the image.
For example, show one decimal value in the x-axis tick labels using '%. 1f' . Display the y-axis tick labels as British Pounds using '\xA3%. 2f' .
My workaround similar to @j_kubik proposition:
plot(1:10)
% get handle to current axes
a = gca;
% set box property to off and remove background color
set(a,'box','off','color','none')
% create new, empty axes with box but without ticks
b = axes('Position',get(a,'Position'),'box','on','xtick',[],'ytick',[]);
% set original axes as active
axes(a)
% link axes in case of zooming
linkaxes([a b])
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