Display wireframe mesh in matlab and save as vector graphics

Alec Jacobson

January 14, 2012

weblog/

For our siggraph submission I wanted to overlay a 2D image with the wireframe of the mesh we use to deform it. In matlab I can display a 2D mesh (V,F) easily using:
trisurf(F,V(:,1),V(:,2),0*V(:,1));
view(2);
axis equal;
If I save this as .eps then I get a nice vector graphics version of my mesh. But if I don't want the filled faces to show up in the vector output, then when I try to save the following figure as a .eps file:
trisurf(F,V(:,1),V(:,2),0*V(:,1),'FaceAlpha',0);
view(2);
axis equal;
matlab just pretends to make a postscript vector file but instead its just a .eps file containing a raster image. Here's what I do to get a .eps vector graphics postscript file (which can then be turned into a PDF since output to PDF is broken in matlab):
E = edges(F);
plot([V(E(:,1),1) V(E(:,2),1)]',[V(E(:,1),2) V(E(:,2),2)]','k-');
view(2);
axis equal
set(gcf, 'Color', [1,1,1]);
set(gca, 'visible', 'off');