Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matlab remove only top and right ticks with leaving box on

Tags:

plot

matlab

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.

like image 883
Daisuke Takeshita Avatar asked Mar 21 '13 17:03

Daisuke Takeshita


People also ask

How do I hide tick marks in Matlab?

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

How do I remove the top line from a graph in Matlab?

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.

How do I specify a tick mark in Matlab?

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' .


1 Answers

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])
like image 76
mc2 Avatar answered Nov 15 '22 19:11

mc2