TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to plot the surface

$S=\{(x,y,z)\in\mathbb{R}^3\ z=xy\}$

for an exercise of affine geometry but I am a novice in graphics! Can I use GeoGebra? or TikZ or Asymptote?

share|improve this question
Yes, you can use GeoGebra! It has export to PSTricks code, TikZ code or export as a graphics in pdf, eps or png format. – matth Jan 19 '12 at 13:27
@matth: except that to plot 3d surfaces, he would need Geogebra 5, and as far as I can tell, it does not support exporting as a graphics yet. – Jan Hlavacek Jan 19 '12 at 14:14

You can use the pgfplots package at will. Please check the manual for lots of other possibilities such as view angle, shader types etc.

\addplot3[surf,shader=faceted] {x*y};

enter image description here

share|improve this answer
This 3D plot is in orthographic projection. Is perspective view also possible with pgfplots? – AlexG Jan 19 '12 at 9:42
@AlexanderGrahn: No, pgfplots can't do perspective plots yet. You might want to take a look at PStricks for that. – Jake Jan 19 '12 at 9:46
Many thanks percusse, I will try your code with Texgraph too: – amine Jan 19 '12 at 16:30

run with latex->dvips->ps2pdf or with xelatex (that takes some time)


\psset{viewpoint=60 20 15 rtp2xyz,Decran=70,lightsrc=viewpoint}
 \psSurface[ngrid=.2 .2,incolor=yellow,linewidth=0.3pt,
 axesboxed,algebraic,hue=0 1](-2,-2)(2,2){ x*y }


enter image description here

share|improve this answer
Many thanks Herbert! I will try also the following: \begin{texgraph}[name=surface,export=tkz] viewDir(-30,60), view(-5,5,-6,5), view3D(-2,2,-2,2,-4,4), BoxAxes3D(LabelSize:=tiny), FillColor:=lightblue, Dsurface(M(u,v,u*v), -2+2*i,-2+2*i) \end{texgraph} – amine Jan 19 '12 at 16:31

You can also use asymptote, the following will produce the plot you want:

import graph3;
import grid3;
import palette;




real f(pair z) {return z.x*z.y;}

surface s=surface(f,(-1/2,-1/2),(1/2,1/2),50,Spline);



3d plot produced by asymptote

Another advantage of using asymptote is that if you produce a pdf by running asy -f pdf yourfile.asy, and view it in Adobe reader, it will render the actual 3d model, and you will be able to rotate it, zoom in and out, change the way it is displayed, etc. You can then include the 3d model in your LaTeX document usingthe movie15 package.

Another option is Metapost with the mp-solid module. There is a documentation (in French) and number of examples here.

share|improve this answer
To keep the separate PRC 3D file for later inclusion, asy option -k is necessary. – AlexG Jan 19 '12 at 15:10
Many thanks Jan Hlavacek! – amine Jan 19 '12 at 16:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.