필터 지우기
필터 지우기

How to remove ticks from the x-axis?

조회 수: 903 (최근 30일)
Vahid
Vahid 2012년 3월 18일
댓글: Shaojun Liao 2023년 4월 5일
Hi everybody,
I am wondering if there is any way to remove the ticks from only one axis, let say x-axis, when you plot a graph. (TickLength applies the changes to both x- and y-axis which is not what I'd like)
Thank you very much in advance, Vahid

채택된 답변

bym
bym 2012년 3월 18일
set(gca,'XTick',[])

추가 답변 (3개)

Bryan Conklin
Bryan Conklin 2019년 8월 27일
편집: Bryan Conklin 2019년 8월 27일
h=gca; h.XAxis.TickLength = [0 0];
This will allow you to keep the labels but remove the tick marks on only the x-axis.
  댓글 수: 2
Fenglei Gu
Fenglei Gu 2022년 3월 29일
Thanks!!!! searched for a long time!
Shaojun Liao
Shaojun Liao 2023년 4월 5일
Thank you so much for helping, hope more people can see it. Because your answer is exactly related to the point.

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


Hossein
Hossein 2017년 10월 18일
but how to keep the numbers?
  댓글 수: 2
Sarah Zinn
Sarah Zinn 2017년 12월 13일
편집: Sarah Zinn 2017년 12월 13일
I use
set(gca,'TickLength',[0 0])
but it will affect the YTick as well.
Aditya Aji wibowo
Aditya Aji wibowo 2019년 5월 26일
Thank's, it works.

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


Walter Fanka
Walter Fanka 2018년 12월 20일
set(gca,'TickLength',[0 .01])
% where 0 is the length of ticks on the x-axis and
% .01 is the length on the y-axis.
So in this case, the x-axis is "tickless" :)
  댓글 수: 2
LeChat
LeChat 2020년 10월 28일
This is nice, but would there be a way to remove the ticks only on one side of the graph, and not the one facing it? I would like to have ticks on the main axis but no mirror ticks (I have a box around my graph and I do not want ticks on the other sides of the box). Thank you for your help!
LeChat
LeChat 2020년 10월 28일
oh actually I found this which works great:
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])
from:
https://stackoverflow.com/questions/15553720/matlab-remove-only-top-and-right-ticks-with-leaving-box-on

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

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by