I know that it is possible to embed three-dimensional files into PDFs with \LaTeX which can then actively be interacted with by the reader (see here for example).

I have a surface plot I made with pgfplots. Is there any way to have this surface plot interactive, i.e. to make it like so that the reader can rotate the surface as he/she wishes?

This will obviously only work with a limited set of readers (probably only recent versions of Adobe Reader), but for the sake of trying I'm willing to work with the consequences of this.

2 Answers 2


Pgfplots supports two-dimensional projections only.

  • I probably couldn't get a more precise answer :)
    – Habi
    Oct 10, 2013 at 7:35
  • 1
    Well, two years ago I thought about implementing support for interactive 3d graphics in pgfplots because it appears to be interesting. But it is also very involved... Oct 10, 2013 at 20:58
  • 1
    Here is a further remark for others who might have stumbled over this answer: pgfplots supports interactive results - just for different use-cases: you can click on data points and the reader displays customizable meta data. Refer to the clickable lib of pgfplots for details. Nov 10, 2013 at 13:17

I'm not sure whether you can do this with pgfplots, but Asymptote excels at this sort of thing.

For example, here is a MWE, in the form of a Beamer slide, that includes an interactive figure I created for a lecture on multiple regression. If you open this is Acrobat Reader you can click on the plot and then rotate, zoom, etc.

Since I like to keep my LaTeX and figure code separate I split this into two files, asyslide.tex and multiregr.asy.



  \frametitle{Geometry of Multiple Regression}



import three;

/* draw the X,Y-plane */
path3 xplane = (0,0,0)--(2,0,0)--(2,2,0)--(0,2,0)--cycle;

/* X vectors */
path3 x1 = (0,0,0)--(1.75,1,0); 
draw(Label("$\mathbf{x}_1$", 1),x1,Arrow3);

path3 x2 = (0,0,0)--(0.5,1.9,0);
draw(Label("$\mathbf{x}_2$", 1, align=S),x2,Arrow3);

path3 y= (0,0,0)--(1.8, 1.5,1.2);
draw(Label("$\mathbf{y}$", 0.75, align=2*W),y,Arrow3);

/* Project Y into subspace of Xs */
path3 projy = planeproject(xplane)*y;
triple endpoint = invert(point(length(projy))); 

draw(Label("$\mathbf{\widehat{y}}$", 1, align=E),projy,red,Arrow3);
draw(Label("$\mathbf{e}$", 0.75,align=RightSide),(1.8,1.5,0)--(1.8,1.5,1.2),red+dashed,Arrow3);

You can compile this example as:

pdflatex asyslide.tex
asy asyslide*.asy
pdflatex asyslide.tex

This generates the following output:

Asymptote 3D Example:Multiple Regression

  • At work (Scientific Linux 6, Texlive 2012), I cannot complete the asy asyslide*.asy step. I get informed that the runtime does not support onscreen rendering, that I should install the glut library (I have freeglut), run ./configure, and recompile. Including switching from pgfplots to Asymptote that seems like a big step unfortunately.
    – Habi
    Oct 10, 2013 at 7:40
  • 2
    @Habi: Unfortunately I can't help you with Asymptote issues you're running into on Scientific Linux, as I primarily use the build of Asymptote that is distributed with MacTeX and it's always just worked "out of the box." Asymptote is very powerful, so if you anticipate doing lots of technical illustrations it's probably worth the effort to get it working. But if this is just a "one off" need than you may want to consider keeping things simple and using the non-interactive pgfplot you've already created.
    – Paul M.
    Oct 10, 2013 at 12:55
  • At the moment I only wanted to have plots interactive, switching my workflow from pgf/TikZ to Asymptote seems overkill for that. Even though your answer is great, I still accepted the (negative) answer from the author of pgfplots below.
    – Habi
    Oct 18, 2013 at 9:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .