How do I remove the bottom line of the axes in a saved figure?
Mostrar comentarios más antiguos
I drew a graph and deleted axes by using the code below.

% 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.

% 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.

% 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!

% 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 comentarios
KSSV
el 10 de Oct. de 2017
axis off
Gianluca Di Muro
el 3 de Ag. de 2018
Editada: Gianluca Di Muro
el 3 de Ag. de 2018
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.
Respuesta aceptada
Más respuestas (1)
Akira Agata
el 10 de Oct. de 2017
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');

2 comentarios
Sungwoo Park
el 11 de Oct. de 2017
Did you try setting 'XColor' and 'YColor' to 'none'? Also, export using export_fig instead of PRINT.
Categorías
Más información sobre Title en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!