LaTeX nerd LaTeX blog

3D Plot

Check page 77 of the notes, from CO 255.

\begin{tikzpicture}[scale=1.5]
\begin{axis}[
3d box=background,
enlargelimits=true,
colormap/cool,
xlabel=\empty,
ylabel=\empty,
zlabel=\empty,
xtick=\empty, ytick=\empty,ztick=\empty
]
\addplot3 [domain=-4:4,domain y=-4:4,
surf,
shader=interp,
samples=50,
z buffer=sort,
]  {x^2+y^2+2};
\node[circle,fill,inner sep=1pt] at (axis cs:0,0,2) {};
\node[circle,fill,inner sep=1pt] at (axis cs:2,2,10) {};
\draw (axis cs:0,0,2) .. controls (axis cs:1,1,3) and  (axis cs:1.5,1.5,6.5) .. (axis cs:2,2,10);

\draw (axis cs:0,0,0) -- (axis cs:2,2,0);
\draw [dotted] (axis cs:0,0,2) -- (axis cs:0,0,0);
\draw [dotted] (axis cs:2,2,10) -- (axis cs:2,2,0);
\node[label={270:{$\bar x$}},circle,fill,inner sep=1pt] at (axis cs:0,0,0) {};
\node[label={270:{$x^*$}},circle,fill,inner sep=1pt] at (axis cs:2,2,0) {};

\end{axis}
\end{tikzpicture}