# Help to plot a surface

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?

-
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.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[grid=both]
\end{axis}
\end{tikzpicture}
\end{document}


-
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)

\documentclass{article}
\usepackage{pst-solides3d}
\begin{document}

\psset{viewpoint=60 20 15 rtp2xyz,Decran=70,lightsrc=viewpoint}
\begin{pspicture}(-4,-6)(5,8.7)
\psframe[fillstyle=solid,fillcolor=blue!10](-4,-6)(5,8.7)
\psSurface[ngrid=.2 .2,incolor=yellow,linewidth=0.3pt,
axesboxed,algebraic,hue=0 1](-2,-2)(2,2){ x*y }
\end{pspicture}

\end{document}


-
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;

currentprojection=perspective(12,23,1.5);

size(400,300,IgnoreAspect);

defaultrender.merge=true;

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

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

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

grid3(XYZgrid);


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.

-
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