How do I remove the bottom line of the axes in a saved figure?
20 ビュー (過去 30 日間)
古いコメントを表示
I drew a graph and deleted axes by using the code below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/168034/image.png)
% code
hAxes = gca;
hAxes.XRuler.Axle.LineStyle = 'none';
axis off
However, when I added lines by using 'line' commend to explain each components, the axis at the bottom appeared again as shown below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/168036/image.png)
% code
x=[-19,-14];
y=[0,0];
line(x,y,'color','k');
x=[-19,-14];
y=[0.6,0.6];
line(x,y,'color','k');
x=[-16.5,-16.5];
y=[0,0.6];
line(x,y,'color','k');
I don't know why axis appeared again. Anyway, I drew white lines to hide black axis as shown below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/168037/image.png)
% code
x=[0,-14];
y=[0,0];
line(x,y,'color','white','linewidth',2);
x=[100,120];
y=[0,0];
line(x,y,'color','white','linewidth',2);
OK. It looks good to me. However, when I saved the graph as a pdf image, the axes appeared again!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/168038/image.png)
% code
set(gcf,'Units','Inches');
pos = get(gcf,'Position');
set(gcf,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)]);
print(gcf,[fig_file,'powerexp'],'-dpdf','-r300');
Please somebody save me~!!!!
T-T
2 件のコメント
Gianluca Di Muro
2018 年 8 月 3 日
編集済み: Gianluca Di Muro
2018 年 8 月 3 日
and
hold on
Whatever the method you use, if you do not hold the axis, it will be rendered again with default settings, as soon as you add new children to it.
採用された回答
Abby Skofield
2018 年 10 月 16 日
編集済み: MathWorks Support Team
2018 年 11 月 28 日
If you do not want the axes outline to appear, you can turn it off using this command:
axis off
If you have an area, bar, or stem plot that has a baseline and want to turn off the baseline, set the Visible property of the Baseline object to 'off', for example:
a = area(magic(5));
a(1).BaseLine.Visible = 'off';
If those approaches do not resolve the problem, you can try preserving the plot colors when printing or saving by setting the InvertHardcopy property of the Figure object to 'off' before printing, for example:
set(gcf,'InvertHardCopy','off','Color','white');
その他の回答 (1 件)
Akira Agata
2017 年 10 月 10 日
By setting the 'Visible' property of the axes 'off' after plotting your graph, you can remove the axes. Following is a simple example.
% Plotting your graph, like:
plot(magic(4))
% Set the 'visible' property 'off'
ax = gca
ax.Visible = 'off'
% The axes is removed from PDF file, too.
print(gcf,'-dpdf','-r300');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178577/image.png)
2 件のコメント
Cedric
2017 年 10 月 11 日
編集済み: Cedric
2017 年 10 月 11 日
Did you try setting 'XColor' and 'YColor' to 'none'? Also, export using export_fig instead of PRINT.
参考
カテゴリ
Help Center および File Exchange で Graphics Object Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!