5.0

5.0 | 3 ratings Rate this file 136 downloads (last 30 days) File Size: 2.17 KB File ID: #17928

FIXPSLINESTYLE

by Jiro Doke

 

07 Dec 2007 (Updated 10 Dec 2007)

Code covered by BSD License  

Fixes line styles in postscript files created from MATLAB (PRINT command)

Download Now | Watch this File

File Information
Description

FIXPSLINESTYLE: Fix line styles in exported post script files
 
FIXPSLINESTYLE(FILENAME) fixes the line styles in the postscript file FILENAME. The file will be over-written. This takes a .PS or .EPS file and fixes the dotted and dashed line styles to be a little bit more esthetically pleasing. It fixes the four default line styles (line, dotted, dashed, dashdot).
 
FIXPSLINESTYLE(FILENAME, NEWFILENAME) creates a new file NEWFILENAME.
 
This is meant to be used with postscript files created by MATLAB (print, export).

Example:
  x = 1:.1:10;
  y1 = sin(x);
  y2 = cos(x);
  h = plot(x, y1, '--', x, y2, '-.');
  set(h, 'LineWidth', 2);
  grid on;
  legend('line 1', 'line2');

  print -depsc test.eps
  fixPSlinestyle('test.eps','fixed_test.eps');

Acknowledgements
This submission has inspired the following:
fix_lines, export_fig
MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
12 Dec 2007 Eric Magee

This is very nice - I have always wished there was more control over the details of the line styles - guess we just have to mess with the PS file. Would there be any way of not "fixing" the line style of the grid?

14 Dec 2007 K Hamed

A trick I learned a long time ago from a friend is to replace the line: "0 cap" in the postscript file with "1 cap". This makes the edges of the lines rounder, which gives thick lines a nicer look, and also make dots round. Is this recommended or are there any side effects?

15 Dec 2007 Jiro Doke

Eric,
Thanks for your comments. I looked at the PS file and found out a way to not alter the grid. But I haven't figured out how to automate it. You can define another line style, and find out where the grid lines are defined. The issue is that the grid lines are simply defined like any other lines, so it's not straightforward to identify them.

K Hamed,
I'm not sure if it's the "recommended" way (I'm not an expert on Postscript), but "1 cap" or "1 setlinecap" creates a rounded end.

12 Dec 2008 Oliver Woodford

This is a great idea, and one that inspired me to improve my own pdf rendering function, print_pdf. I've managed to get dash lengths to vary with line widths too, and make grid lines dotted rather than dashed. Thanks for the inspiration, Jiro!

22 Jan 2009 Jiro Doke

Thanks for the feedback, Oliver. I'm glad to hear this inspired you to improve your own function. BTW, your print_pdf function is nice. It seems like you figured out a ways to make the grid lines separate from dashed lines.

11 Feb 2009 Jirka Dostal  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
annotation Jiro Doke 22 Oct 2008 09:38:24
customization Jiro Doke 22 Oct 2008 09:38:24
postscript Jiro Doke 22 Oct 2008 09:38:24
post process Jiro Doke 22 Oct 2008 09:38:24
line style Jiro Doke 22 Oct 2008 09:38:24
graphics Jiro Doke 22 Oct 2008 09:38:24
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com