MetaPost – Best Alternatives for Plotting 3D Surfaces

metapost

I find METAPOST to be a wonderful software to create 2d charts and figures.

Can you name me a few good alternatives to METAPOST for drawing 3d surfaces?

The crucial feature I'm looking for is the ability to have all the fonts (the axis labels and all the numbers) in the LaTeX font, just like METAPOST so gracefully allows me to do.

Best Answer

For powerful graphics I would recommend Asymptote. It has a C++-type object-oriented syntax and is not that difficult to learn. Some of the main strong points are (but look at the gallery on the webpage):

  • Full math and linear algebra engine
  • Full 3D including active 3D pictures in PDF
  • Use LaTeX to set all text and math
  • It can be inlined in Latex but it is normaly better to use it for standalone graphics.

Here is a nice one from the gallery of Asymptote examples by GaƩtan Marris

enter image description here

with the code that generated it

import graph3;
import contour;
import grid3;
import palette;

size(8cm,IgnoreAspect);
currentprojection=orthographic(-10,-10,8);
limits((0,0,0),(5,10,12));

real f(pair z) {return (z.x+z.y)/(2+cos(z.x)*sin(z.y));}
real[] lignesniveaux={2,4,6,8};
surface s=surface(f,(0,0),(5,10),50,Spline);

draw(s,mean(palette(s.map(zpart),Rainbow())),black);

grid3(new grid3routines [] {XYXgrid, ZXgrid(10), ZYgrid(5)},
      Step=2,
      step=1,
      pGrid=new pen[] {red, blue, black},
      pgrid=new pen[] {0.5red, lightgray, lightgray});
xaxis3(Label("$x$",position=MidPoint,align=SE),
       Bounds(Min,Min),
       OutTicks());
yaxis3(Label("$y$",position=MidPoint,align=SW),
       Bounds(Min,Min),
       OutTicks(Step=2));
zaxis3(Bounds(Max,Both));
zaxis3(Label("$z$",position=EndPoint,align=N+W),
       XYEquals(0,10),
       InTicks(beginlabel=false,endlabel=false,Label(align=Y)));

draw(lift(f,contour(f,(0,0),(5,10),lignesniveaux)),1bp+red);