Modify code for tick marks to be on the outside?

Hi all,
I copied and pasted this code...I just need a slight modification to get the tick marks to appear on the outside and not on the side of the graph. It is currently set to only have the tick marks on the bottom (x axis) and the left (y axis). I.e. not at the right and at the top.
axis([0,1200,0,70])
% 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])
Many thanks.
J

 채택된 답변

William Frane
William Frane 2014년 8월 14일

8 개 추천

Tick direction is controlled using the TickDir property.
set(gca,'TickDir','out'); % The only other option is 'in'
For reference, a complete list of axes properties is available here.
Hope that helps.

댓글 수: 4

Hello, is any way to set the ticks only in the left Y axe and the low X axe?
Because I need them out, but now I have ticks around all the box and some of them are touching the title area.
You can use the text() function to make a title in a better location for your plot. Or maybe you could use
box off
which will just leave the left and bottom axes (only if you don't need the full box)
银雀Sparr0w
银雀Sparr0w 2023년 5월 15일
편집: 银雀Sparr0w 2023년 5월 15일
No, there is one more option that is 'both'. Actually after R2021b we've got another one 'none'.
The link to Axes Properties is broken. Here's a new link: Axes Properties.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jai
Jai 2014년 8월 14일

1 개 추천

Thank you for your help. It worked perfectly!

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

질문:

Jai
2014년 8월 14일

댓글:

2023년 9월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by