Is it possible to disable axes' edges

조회 수: 11 (최근 30일)
Matthew
Matthew 2012년 7월 17일
답변: Yuri Janson 2023년 6월 9일
Hello,
Im working with handles to create a GUI that will be using several different axes. Can the edges of the axes be removed? I've been searching through the axes properties and I havent seen anything. Can someone please help!
Thanks in advance, Matt

채택된 답변

Sean de Wolski
Sean de Wolski 2012년 7월 17일
So something like:
figure;
axes('box','off','xtick',[],'ytick',[],'ztick',[],'xcolor',[1 1 1],'ycolor',[1 1 1]);
line([0 1],[0 1])
  댓글 수: 2
Jan
Jan 2012년 7월 17일
Exactly: You set the color of the axes lines to either the background color of the axes or of the figure:
figH = figure;
bg = get(figH, 'Color');
axes('xcolor', bg, 'ycolor', bg);
To remove the ticks also, see Sean's code.
Matthew
Matthew 2012년 7월 18일
편집: Matthew 2012년 7월 18일
Worked like a charm, thanks Sean!

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

추가 답변 (4개)

Walter Roberson
Walter Roberson 2012년 7월 17일
The only way to remove the edge of the axes is to set the axes visibility to be off. That will also make the tick marks invisible, along with any grid lines.
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 7월 18일
Visible
{on} | off
Visibility of axes. By default, axes are visible. Setting this property to off prevents axis lines, tick marks, and labels from being displayed. The Visible property does not affect children of axes.
Sounds to me exactly what you are looking for.
Matthew
Matthew 2012년 7월 19일
I thought visable would be like setting alpha equal to 0. However, I was wrong. This worked much easier, its just one property setting to modify.
Thanks Walter!

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


Image Analyst
Image Analyst 2012년 7월 18일
Matthew, If you have the Image Processing Toolbox, go to File->Preferences->Image Processing->IMSHOW Display and uncheck the "Axes visible" box. That will eliminate any black line around the edge of your images if you use imshow() to display your image.
  댓글 수: 1
Deependra Mishra
Deependra Mishra 2020년 1월 10일
Is there anyway this can be unchecked programmatically?

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


Christopher Bitikofer
Christopher Bitikofer 2022년 8월 11일
This took me too long to figure out. The axes are objects with lots of fun properties including visibility
ax.XAxis.Visible = 'off';

Yuri Janson
Yuri Janson 2023년 6월 9일
If you do not want the axes themselves to show, but do want the axis label and/or tick labels to show, then you can do the following:
ax = gca;
% Set color of X and Y axes to background color (white)
set(ax,'XColor',[1 1 1])
set(ax,'YColor',[1 1 1])
% Set color of axis labels back to standard color
set(ax.XLabel,'Color',[0.15 0.15 0.15])
set(ax.YLabel,'Color',[0.15 0.15 0.15])
% Set color of tick labels back to standard color
set(ax.XAxis,'TickLabelColor',[0.15 0.15 0.15])
set(ax.YAxis,'TickLabelColor',[0.15 0.15 0.15])

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by