source: MML/trunk/machine/SOLEIL/common/toolbox/export_fig/print2eps.m @ 17

Last change on this file since 17 was 17, checked in by zhangj, 10 years ago

To have a stable version on the server.

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1%PRINT2EPS  Prints figures to eps with improved line styles
2%
3% Examples:
4%   print2eps filename
5%   print2eps(filename, fig_handle)
6%   print2eps(filename, fig_handle, options)
7%
8% This function saves a figure as an eps file, and improves the line style,
9% making dashed lines more like those on screen and giving grid lines their
10% own dotted style.
11%
12%IN:
13%   filename - string containing the name (optionally including full or
14%              relative path) of the file the figure is to be saved as. A
15%              ".eps" extension is added if not there already. If a path is
16%              not specified, the figure is saved in the current directory.
17%   fig_handle - The handle of the figure to be saved. Default: gcf.
18%   options - Additional parameter strings to be passed to print.
19
20% Copyright (C) Oliver Woodford 2008-2009
21
22% The idea of editing the EPS file to change line styles comes from Jiro
23% Doke's FIXPSLINESTYLE (fex id: 17928)
24% The idea of changing dash length with line width came from comments on
25% fex id: 5743, but the implementation is mine :)
26
27function print2eps(name, fig, varargin)
28options = {'-depsc2'};
29if nargin < 2
30    fig = gcf;
31elseif nargin > 2
32    options = [options varargin];
33end
34% Construct the filename
35if numel(name) < 5 || ~strcmpi(name(end-3:end), '.eps')
36    name = [name '.eps']; % Add the missing extension
37end
38% Set paper size
39old_mode = get(fig, 'PaperPositionMode');
40set(fig, 'PaperPositionMode', 'auto');
41% Print to eps file
42print(fig, options{:}, name);
43% Reset paper size
44set(fig, 'PaperPositionMode', old_mode);
45% Fix the line styles
46try
47    fix_lines(name);
48catch
49    warning('fix_lines failed. This is usually because the figure contains a large number of patch objects. Consider exporting to a bitmap format in this case.');
50end
51return
Note: See TracBrowser for help on using the repository browser.