Line markers disappeared after save as .eps/.emf when yyaxis was used

Dear all,
I am currenty having the issues about disappeared line markers in the exported figures. The simplified example code is showing below:
clc, clear all
x = 1:10;
y1= 1*x;
y2= 0*x;
figure
newcolors = [1 0 0; 0 0 1];
colororder(newcolors);
[hAx,hLine1,hLine2] = plotyy(x,y2, x,y1); hold on
hLine1.LineStyle = '-';
hLine1.Marker = 'o';
hLine2.LineStyle = '--';
hLine2.Marker = 's';
ax = gca;
ax.YLim = ([0 1]);
figure
newcolors = [1 0 0; 0 0 1];
colororder(newcolors);
yyaxis left
plot(x,y2, ' o-'); hold on
ylim([0 1])
yyaxis right
plot(x,y1, ' s--'); hold on
For both methods, the pop-up figures have no issues. However, after saving the figures as .eps/.emf, the line markers disappears if yyaxis was used, while there is no issue if plotyy was used.
I could use plotyy for the figure plotting. However, I am wondering if someone help me with using yyaxis for the figure plotting? Many thanks.

 Respuesta aceptada

Hi,
Can you elaborate on how you are trying to save your figure as '.eps' file, and the application you are using to view the eps file.
At my end, I am proceeding as follows:
clc, clear all
x = 1:10;
y1= 1*x;
y2= 0*x;
figure
newcolors = [1 0 0; 0 0 1];
colororder(newcolors);
[hAx,hLine1,hLine2] = plotyy(x,y2, x,y1); hold on
hLine1.LineStyle = '-';
hLine1.Marker = 'o';
hLine2.LineStyle = '--';
hLine2.Marker = 's';
ax = gca;
ax.YLim = ([0 1]);
print('fig1','-depsc2');
figure
newcolors = [1 0 0; 0 0 1];
colororder(newcolors);
yyaxis left
plot(x,y2, ' o-'); hold on
ylim([0 1])
yyaxis right
plot(x,y1, ' s--'); hold on
print('fig2','-depsc2');

5 comentarios

Hi Harsha,
Thanks for your help. I usually save the figure by click on the pop-up figure 'file' > 'save as' .eps'. The application I used to view the eps file is Adobe Illustrator (AI).
I have tried to run your code and save the eps file as provided code. I could see the line markers in the pop-up figures. However, I still could not see the line markers in the saved eps figure via AI.
Could you have a look of it? Or alternatively, any software that I could use to view and edit the figures?
Many thanks.
Zelong
Hi,
I brought this issue to the concerned people. In the mean time can you try the suggestion in the following thread.
Hi,
The solution for your problem will be solved if you set Clipping Style of yyaxis to '3d box'.
yyax = findall(gcf, 'type', 'axes');
yyax.ClippingStyle='3dbox'
Hope this solves your issue!
Perfect! It works! Thanks so much for your help!
Hi,
I used the solution of setting the ClippingStyle to '3dbox' but I get the correct Line Markers only on one plot and not the other plot.

Iniciar sesión para comentar.

Más respuestas (1)

What worked for me was adding the following before exporting the EPS file:
ax = gca;
ax.Clipping = 'off';

Categorías

Etiquetas

Preguntada:

el 11 de Mayo de 2020

Respondida:

el 28 de Mayo de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by