MATLAB Answers

How do I remove the border lines surrounding an axes?

1,656 ビュー (過去 30 日間)
When I make a simple plot, I would like to turn off the border around the axes. However,
box off
removes only part of the border. I have removed all of the tick marks and labels, but there are still 2 border lines present. Is there a way to remove them?
You can reproduce the issue as follows:
hAx = axes;
set(hAx, 'box','off','XTickLabel',[],'XTick',[],'YTickLabel',[],'YTick',[])

採用された回答

MathWorks Support Team
MathWorks Support Team 2009 年 6 月 27 日
The ability to remove all of the border lines surrounding an axes is not available in MATLAB.
Depending on your application, you might be able to use one of the following options as a workaround:
1. You can change the 'XColor' and 'YColor' properties of the axes to match the color of the background of the figure. This makes the axis lines invisible against the figure background. You must also eliminate the tick marks and minor tick marks that extend into the axes. The easiest way to do this is to change their direction such that they point outward, as opposed to inward. For example:
hFig = figure;
plot(1:10)
color = get(hFig,'Color');
set(gca,'XColor',color,'YColor',color,'TickDir','out')
2. Make the axes invisible by setting the axes 'Visible' property to 'off'. For example:
plot(1:10)
set(gca,'Visible','off')

  2 件のコメント

Anton Rodenhauser
Anton Rodenhauser 2017 年 6 月 24 日
The Problem with the provided solutions is that they also make the grid disappear. Is it really not possible to remove all border lines surrounding an axes but keep the ticklabels and the grid?
Alan Baker
Alan Baker 2017 年 12 月 1 日
In Matlab 2017b, you can use
set(gca,'XColor','none')
to remove the "border" along the X axis

サインイン to comment.

その他の回答 (1 件)

Hamid Fehri
Hamid Fehri 2018 年 3 月 22 日
編集済み: Hamid Fehri 2018 年 3 月 22 日

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

製品


リリース

R2006a

Translated by