How to delete axes and tick in figure?

조회 수: 47 (최근 30일)
Gifari Zulkarnaen
Gifari Zulkarnaen 2020년 1월 10일
답변: dpb 2020년 1월 10일
I make a contour plot, and then add another line plot in the same figure. For example:
contour(x,y,z)
hold on
plot(xx,yy)
hold off
I want to delete axes and tick of the figure, how to do it?
I tried these command, but didn't work:
set(gcf,'XTick',[], 'YTick', [])
set(gcf,'XColor','none','YColor','none')
Error shown: "There is no XTick (or XColor) property on the Figure class"
  댓글 수: 3
Gifari Zulkarnaen
Gifari Zulkarnaen 2020년 1월 10일
I see! Thanks a lot, it works.
Hope your answer is in answer section so that I can accept it.
Adam Danz
Adam Danz 2020년 1월 10일
For completeness, here are two interpretations of "How to delete axes "
axis off % axis content will remain, the axis itself will vanish
delete(gca) % will destroy the axis and everything in it

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

채택된 답변

dpb
dpb 2020년 1월 10일
Precisely. As your question says, you're trying to mess with axis properties, not those of the figure.
Substitute
hAx=gca; % get current axes handle
set(hAx,...) % set desired property
There are routines specific for the ticks or the "dot" notation besides set
OK...did move content to Answer per request. :)
One additional note -- the above retrieves the current axes handle first, then uses it. This ensures always referring to the same axis in the event of some user interaction that could change focus.
Even better is to save the handle when the axes is created (although plot and friends will create one for themselves in which case the above is the way to retrieve it immediately).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by