Thread Subject: EPS export_fig and dashed lines

Subject: EPS export_fig and dashed lines

From: Luca Cerone

Date: 6 Jan, 2012 14:09:08

Message: 1 of 5

Dear all,
I've to export so plots containing dashed lines as eps.
In order to do this I'm using the nice function export_fig available in File's Exchange
( http://www.mathworks.com/matlabcentral/fileexchange/23629 )
using the painters renderere: export_fig myfig.eps -painters

Everything works fine, but the dashed lines are not displayed properly in the final eps.
They are too few, so that in region where the segments are short, one can't really tell
if they are solid or actually dashed.

I think one of the problem might be that this lines are obtained by plotting a lot of points
in a relatively short space.

Is there any way I can make the eps display the dashed lines correctly?
I've tried to use also the fix_lines function but I can't display the output: it seems
it is not a proper EPS.

Thanks a lot in advance for your help.
Cheers, -luca

Subject: EPS export_fig and dashed lines

From: Oliver Woodford

Date: 7 Jan, 2012 11:41:07

Message: 2 of 5

"Luca Cerone" wrote:
> Dear all,
> I've to export so plots containing dashed lines as eps.
> In order to do this I'm using the nice function export_fig available in File's Exchange
> ( http://www.mathworks.com/matlabcentral/fileexchange/23629 )
> using the painters renderere: export_fig myfig.eps -painters
>
> Everything works fine, but the dashed lines are not displayed properly in the final eps.
> They are too few, so that in region where the segments are short, one can't really tell
> if they are solid or actually dashed.
>
> I think one of the problem might be that this lines are obtained by plotting a lot of points
> in a relatively short space.
>
> Is there any way I can make the eps display the dashed lines correctly?
> I've tried to use also the fix_lines function but I can't display the output: it seems
> it is not a proper EPS.
>
> Thanks a lot in advance for your help.
> Cheers, -luca

Hello
Can you post a small amount of code (e.g. to plot a figure) which recreates the problem you're seeing?
Thanks,
Oliver

Subject: EPS export_fig and dashed lines

From: Luca Cerone

Date: 7 Jan, 2012 12:59:09

Message: 3 of 5

> Can you post a small amount of code (e.g. to plot a figure) which recreates the problem you're seeing?
> Thanks,
> Oliver

Hi Oliver, thanks first of all!
this is a little artificial, but it kind of recreate the issue:

%% These are the Default Plot Properties I have in my startup.m
set(0,'DefaultFigurePaperPositionMode','auto')
set(0,'DefaultFigureColor','White')
set(0,'DefaultTextInterpreter','Tex')
set(0,'DefaultTextFontName','TimesNewRoman')
set(0,'DefaultTextFontSize',12)
set(0,'DefaultLineLineWidth',2)
set(0,'DefaultAxesLineWidth',1)
set(0,'DefaultAxesBox','off')
%%
x1=linspace(0,.5,1001);
y1=zeros(1,1001);
x2=linspace(.5,.55,2000);
y2=x2-.5;
x3=linspace(.55,1,1001);
y3=.05*ones(1,1001);
%%
close all
figure('PaperUnits','inches','PaperSize',[4 3])
plot(x1,y1);
hold on
plot(x2,y2,'--');
plot(x3,y3);
axis([0 1 0 1]);
export_fig test.eps -painters

The problem is that in the Matlab figure I see 3 dashes for the dashed line,
but in the eps I see only two dashes separated by a small space.

Using zbuffer or opengl creates the exact number of lines as appear in the matlab figure but I don't like the way all the other stuff is rendered.

If you can find a solution you would really give me a huge help!
Thanks a lot in advance,
Luca

Subject: EPS export_fig and dashed lines

From: Oliver Woodford

Date: 9 Jan, 2012 16:57:08

Message: 4 of 5

"Luca Cerone" wrote:
> > Can you post a small amount of code (e.g. to plot a figure) which recreates the problem you're seeing?
> > Thanks,
> > Oliver
>
> Hi Oliver, thanks first of all!
> this is a little artificial, but it kind of recreate the issue:
>
> %% These are the Default Plot Properties I have in my startup.m
> set(0,'DefaultFigurePaperPositionMode','auto')
> set(0,'DefaultFigureColor','White')
> set(0,'DefaultTextInterpreter','Tex')
> set(0,'DefaultTextFontName','TimesNewRoman')
> set(0,'DefaultTextFontSize',12)
> set(0,'DefaultLineLineWidth',2)
> set(0,'DefaultAxesLineWidth',1)
> set(0,'DefaultAxesBox','off')
> %%
> x1=linspace(0,.5,1001);
> y1=zeros(1,1001);
> x2=linspace(.5,.55,2000);
> y2=x2-.5;
> x3=linspace(.55,1,1001);
> y3=.05*ones(1,1001);
> %%
> close all
> figure('PaperUnits','inches','PaperSize',[4 3])
> plot(x1,y1);
> hold on
> plot(x2,y2,'--');
> plot(x3,y3);
> axis([0 1 0 1]);
> export_fig test.eps -painters
>
> The problem is that in the Matlab figure I see 3 dashes for the dashed line,
> but in the eps I see only two dashes separated by a small space.
>
> Using zbuffer or opengl creates the exact number of lines as appear in the matlab figure but I don't like the way all the other stuff is rendered.
>
> If you can find a solution you would really give me a huge help!
> Thanks a lot in advance,
> Luca

I don't know how you can get the dashes exactly the same in an eps as in the figure; fix_lines.m only improves the style. I suggest you use dotted rather than dashed lines for short segments, though.

Subject: EPS export_fig and dashed lines

From: Luca Cerone

Date: 9 Jan, 2012 17:37:08

Message: 5 of 5

>
> I don't know how you can get the dashes exactly the same in an eps as in the figure; >fix_lines.m only improves the style. I suggest you use dotted rather than dashed lines for >short segments, though.

Hi Oliver, thanks for the advice. The problem though is that if I plot them as dotted,
the points are so dense that it seems just a solid line...

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
eps Luca Cerone 6 Jan, 2012 09:14:09
export_fig Luca Cerone 6 Jan, 2012 09:14:09
figure Luca Cerone 6 Jan, 2012 09:14:09
plots Luca Cerone 6 Jan, 2012 09:14:09
dashed line Luca Cerone 6 Jan, 2012 09:14:09
rssFeed for this Thread

Contact us at files@mathworks.com