image thumbnail

figure2eps: version 1.2

by

 

27 Jun 2013 (Updated )

Combine vector graphics, e.g. text, axis etc. with bitmap graphics for surfaces in one eps file.

Demonstration of figure2eps

Demonstration of figure2eps

This demonstrates some of the possabilities of generating combined vector and bitmap eps files from asingle figure. This is helpfull when large surface data is being generated which leads to figures in a document which are very time consuming to open.

figure2eps.m ensures that the axes, text, normal line plots, etc are generated using vector graphics and that large surfaces are output as bitmaps. This makes large files but can be efficientls distilled to compacht .pdf documentation.

The tool is primariarly aimed at publishing with LATEX

The HTML publish document automatically generated by MATLAB (this file) can not truely represent the strengths of this tool, since the graphics are not generated using the figure2eps.m. Nevertheless, it does give an impression of the possabilities.

(c) 2013 Paul O'Leary and Matthew harker

Contents

close all;
clear all;
%
% I have commented out the floowing line of code, because I keep
% encountering a problem in conjunction with the opengl renderer. I don't
% understand the reason. However, removing this line of code solves the
% problem.
%
% set(0,'DefaultFigureColor',[1,1,1]);
%
disp('----------------------------------------------------------------');
disp('figure2eps - Demonstration 1');
disp('----------------------------------------------------------------');
disp('This file will produce the warning:');
disp('Warning: Setting the ColorSpec to ''none'' for a figure will');
disp('not be allowed in a future release');
disp(' ')
disp('We will solve this problem when we reach it.');
disp(' ');
disp('This file is slow, due to the generation of lagre .eps files');
%
----------------------------------------------------------------
figure2eps - Demonstration 1
----------------------------------------------------------------
This file will produce the warning:
Warning: Setting the ColorSpec to 'none' for a figure will
not be allowed in a future release
 
We will solve this problem when we reach it.
 
This file is slow, due to the generation of lagre .eps files

Simple Plot Example (painters renderer)

This simple plot figure will automatically use the painters renderer, i.e. it will generate vector graphics.

nrPts = 100;
f = 4;
%
t = linspace(0,1,nrPts);
yt = cos( 2 * pi * f * t );
%
fig1 = figure;
plot( t, yt, 'k');
grid on;
xlabel('Time');
ylabel('f(t)');
%
disp('Writing file 1');
figure2eps( fig1, 'SimplePlotExample');
%
Writing file 1

Small Surface example (painters renderer)

This surface has only a small number of patches as a consequence it will automatically use the painters renderer. the small surface is rendered using vector graphics.

nrGPts = 10;
X = rand( nrGPts );
Y = rand( nrGPts );
Z = rand( nrGPts );
%
fig2 = figure;
surf( X, Y, Z );
xlabel('Distance');
ylabel('Distance');
zlabel('Elevation');
%
disp('Writing file 2');
figure2eps( fig2, 'SmallSurfExample');
%
Writing file 2

Large Surface example (painters renderer for axis, bitmap for surface)

This surface has a large number of patches, consequently the axes will be rendered using the painters renderer and teh surface will be rendered using the zbuffer. The result is saved in one 'eps' file which contains both the vector and raster graphics.

nrGPts = 100;
X = rand( nrGPts );
Y = rand( nrGPts );
Z = rand( nrGPts );
%
fig3 = figure;
surf( X, Y, Z );
xlabel('Distance');
ylabel('Distance');
zlabel('Elevation');
title('Lots of Random Data');
box on;
%
disp('Writing file 3 (This is slow)');
figure2eps( fig3, 'LargeSurfExample');
Writing file 3 (This is slow)
Warning: Setting the ColorSpec to 'none' for a figure will not be allowed in a
future release. 

Test with an Image (Painters and bitmap)

This is a simple example of using an image toegther with axes in vector graphics.

[pic, map] = imread( 'Snails.png' );
%
fig4 = figure;
imagesc( pic );
axis image;
title('Fast Snails (just like large .eps files)');
%
disp('Writing file 4');
figure2eps( fig4, 'ImageExample');
%
Writing file 4

Transparant Surface (Painters and opengl)

This example combines the painters renderer for the text and axis with the opengl renderer for a transparent surface.

nrGridPts = 100;
[X,Y,Z] = peaks( nrGridPts );
%
fig5 = figure;
surf( X, Y, Z, 'FaceColor', 'interp', 'FaceAlpha', 0.8,'EdgeColor', 'none');
xlabel('x');
ylabel('y');
zlabel('z');
title('Transparent Surface');
%
disp('Writing file 5 (This is slow)');
figure2eps( fig5, 'TransparentExample', 1000, '-opengl');
Writing file 5 (This is slow)
Warning: Setting the ColorSpec to 'none' for a figure will not be allowed in a
future release. 

Contact us