Code covered by the BSD License  

Highlights from
fix_lines

5.0

5.0 | 13 ratings Rate this file 56 Downloads (last 30 days) File Size: 3.11 KB File ID: #23604
image thumbnail

fix_lines

by

 

08 Apr 2009 (Updated )

Improves the style of lines in MATLAB generated eps files

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

This function improves the style of lines in eps files generated by MATLAB's print function, making them more similar to those seen on screen. Grid lines are also changed from a dashed style to a dotted style, for greater differentiation from dashed lines.

The screenshot demonstrates the improvements, with the figure (top right) being printed to eps (bottom left), which is then improved (bottom right) using FIX_LINES. Note how the effect becomes more marked on thicker lines.

The function additionally moves any embedded fonts after the bounding box information, to ensure correct cropping in Ghostscript.

Acknowledgements

Fixpslinestyle inspired this file.

This file inspired Export Fig.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (17)
31 Jan 2014 Jeremy

This is the third fix I've tried for eps figures with default matlab line styles, and it's definitely the best of the three. Thanks!

25 Nov 2013 Xianmin  
15 May 2013 Anton

Thank a lot!

15 Aug 2012 Carl Fischer

Finally! Thanks.

15 Mar 2012 Jered Wells

Although, I do think it would be good to put in a warning if tiff preview is activated in the file being processed. It seems that a flaw which removes plot lines would be something of which the user should be made aware (along with the quick solution)!

15 Mar 2012 Jered Wells

After hours of searching, it would have helped if I scrolled down the page to realize that I simply needed to remove tiff preview. I have no idea why my previous "workaround" worked, but it did. Thanks for your help, works great.

15 Mar 2012 Oliver Woodford

Jered: See my update comment from 18 August 2010. Don't save with tiff preview.

15 Mar 2012 Jered Wells

Strangely enough, when using this program to fix plots with single lines, my line is missing from the plot! When fixing plots with multiple lines, the last line is missing! Even more strangely, when I open the .eps file in a standard text editor like Notepad (Windows 7 system), if I make a small edit (such as add a single space), then re-save, the EPS file loads correctly into my Word document! Ever heard of this problem? I've search everywhere for solutions and cannot seem to find any. Will re-rate when solution is found.

27 Nov 2011 Sauro Salomoni

Great script, does exactly what it's supposed to do. No more annoying thin slashes where there was supposed to be dots! Thanks

25 Aug 2011 Adam Nieslony

You are the best! The tool is simple and do exactly what I have expected. Thank you.

01 Apr 2011 Robert

Excellent! This makes figures look like they do on screen. For those of us who like GUIs, note that this also works if you save figures by clicking File>Save As... and select EPS (which opens in PDF viewers and word processors).

17 Aug 2010 D Ko

Ok, I think I am getting somewhere now. When I remove the tiff preview option, it works just fine. So it seems like it works if the original doesn't have a -tiff attached to it. (I like the preview for when i import the graphic in a WYSIWYG word processor).

17 Aug 2010 D Ko

I tried using the script to improve my matlab-generated eps files (created using print('-depsc2','-tiff','-r600','filename.eps'])), but the output file cannot be read by ghostview.
I get the following message "DOS EPS header is bad". Ignoring DSC comments" in GV.
The Adobe Distiller-generated PDF for the eps file is a blank page.
Any idea?

26 Jul 2010 Seb

Work as i need. Thanks a lot!

03 Jun 2010 Laurence K

Hi, I like this code - it has come in handy!

I was thinking that since the code has some error checking at the top, it should probably also take account of the situation where the file can't be opened. If that's the case at the moment (say the file isn't there) the line:

fh = fopen(fname, 'rt');

returns -1 into fh. That could be checked and acted on below that, for example like this:

[fh, fMsg] = fopen(fname, 'rt');
if ( fh == -1 )
disp(['Error opening file: ' fMsg]);
return;
end

Otherwise, an error is thrown when the fread line is executed, and it goes to close the file on the fclose line just below it. Since it's not open, this throws another error and the code exits with an error before the rethrow line is executed.

17 Jan 2010 Rob Campbell

Clear, well-written code that does the job. Very useful.

06 May 2009 gmart

i fixed the dashed line in my eps figure after running this function...

Updates
14 Jan 2010

Better error recovery. Improved backwards compatibility. Reduced memory requirements.

13 Apr 2010

Move embedded fonts after bounding box info (for R2006b and earlier).

18 Aug 2010

Attempt to fix problem caused by tiff preview, as reported by D Ko (thanks). No error in ghostview now, though last drawn line disappears (only with tiff preview).

18 Aug 2010

Fix bug (only affecting R2006b & earlier) introduced in last update

Contact us