This function is deprecated. Please use EXPORT_FIG (also available on the File Exchange).
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.
Oliver Woodford (2021). fix_lines (https://www.mathworks.com/matlabcentral/fileexchange/23604-fix_lines), MATLAB Central File Exchange. Retrieved .
How should I use this?
It cannot work on matlab r2016a. Please fix it, thanks!
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!
Thank a lot!
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)!
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.
Jered: See my update comment from 18 August 2010. Don't save with tiff preview.
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.
Great script, does exactly what it's supposed to do. No more annoying thin slashes where there was supposed to be dots! Thanks
You are the best! The tool is simple and do exactly what I have expected. Thank you.
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).
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).
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.
Work as i need. Thanks a lot!
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]);
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.
Clear, well-written code that does the job. Very useful.
i fixed the dashed line in my eps figure after running this function...
Inspired by: FIXPSLINESTYLE
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!