Removing Upper XTicks ..or Right Y Ticks..How?
Show older comments
Hi,
I am trying to remove the Xticks that is located only at the upper side and the YTicks that is located right side of my plot.But I could not managed to do it.
I Tried
set(gca, 'XTick',[])
...
set(gca, 'YTick',[])
command but they removed both X ticks up and above or or Both Y Ticks left and right.
Is there any way of removing only one side (up or above...left or right.)
Thanks From Now... Orkun ÖZENER
1 Comment
Arturo Moncada-Torres
on 16 Jun 2011
Could you please also post the code where you are plotting? Maybe even some sample data?
Answers (2)
Bjorn Gustavsson
on 16 Jun 2011
set(gca,'box','off')
2 Comments
Orkun OZENER
on 16 Jun 2011
Bjorn Gustavsson
on 16 Jun 2011
I don't know if you can. Maybe the simplest is just to plot the box manually?
isholdonque = ishold;
hold on
ax = axis;
plot(ax(2)*[1,1],ax(3:4),'k','linewidth',0.5)
plot(ax(1:2),ax(4)*[1,1],'k','linewidth',0.5)
if isholdonque == 0
hold off
end
Arturo Moncada-Torres
on 16 Jun 2011
2 votes
I recommend you to look at this thread, where your same question has already been answered in several ways ;-).
5 Comments
Orkun OZENER
on 16 Jun 2011
CHIO IN
on 30 Aug 2014
I think that thread doesn't answer the question. This thread is talking about removing the upper XTick only.
CHIO IN
on 30 Aug 2014
I found a method to remove the upper XTick, from http://stackoverflow.com/questions/15553720/matlab-remove-only-top-and-right-ticks-with-leaving-box-on
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])
Leon Aksman
on 19 Dec 2018
Works, thanks a lot!
Chaoyue Zhang
on 17 May 2022
It does work! Thank you!
Categories
Find more on Axes Appearance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!