# Pgfplots surf with edge and normal vectors

Is it possible to plot an oriented surface with a thick oriented border? This is MWE:

\documentclass{article}
\usepackage{tikz, pgfplots}
\pgfplotsset{compat=1.11}
\usepgfplotslibrary{colormaps}

\begin{document}
\begin{tikzpicture}
\begin{axis}[hide axis, colormap/bone]
\end{axis}
\end{tikzpicture}
\end{document}


This generates the picture on the left. What I would like is the picture on the right, preferably with a label for the border. As you can see the vectors would be associated to each surface patch.

Any help would be really appreciated. Even a partial solution or a suggestion would be very helpful. Thank you in advance.

This is only a partial answer since deciding which arrows should be drawn in 3d with pgfplots is tricky.

\documentclass[tikz, border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{colormaps}
% from https://tex.stackexchange.com/a/39282/121799
\usetikzlibrary{decorations.markings}
\tikzset{->-/.style={postaction={decorate,decoration={
markings,
mark=at position #1 with {\arrow{>};
\node[font=\sffamily,yshift=7pt] {C};}}}}}
\begin{document}
\begin{tikzpicture}[declare function={f(\x,\y)=\x*\x+\y*\y;}]
\begin{axis}[hide axis, colormap/bone]
orange,thick,-stealth,samples=6,samples y=4,
quiver,quiver/.cd,
u=-x,v=-y,w=1,
scale arrows=-0.4,
] {f(x,y)};
\draw[thick,red,>=stealth,->-=0.5] plot[domain=-5.02:5.02,variable=\x,samples=10]
({\x},5.02,{f(\x,5.02)});
\end{axis}
\end{tikzpicture}
\end{document}


Just for completeness: with asymptote it is very easy to draw such plots. In fact, applying minor modifications to this code yields

\documentclass[border=3.14mm]{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=normals}
import graph3;
size(200,0);

currentprojection=perspective(10,8,4);

real f(pair z) {return abs(z)^2;}
triple F(pair z){ return (z.x,z.y,f(z));}
static real dx=sqrtEpsilon, dy=dx;
return O--((f(z+dx)-f(z-dx))/2dx,
(f(z+I*dy)-f(z-I*dy))/2dy,
-1);
}

//draw((-1,-1,0)--(1,-1,0)--(1,1,0)--(-1,1,0)--cycle);

surface s=surface(f,(-1,-1),(1,1),nx=5,Spline);

xaxis3(Label("$x$"),red,Arrow3);
yaxis3(Label("$y$"),red,Arrow3);
zaxis3(XYZero(extend=true),red,Arrow3);

draw(s,lightgray,meshpen=black+thick(),nolight,render(merge=true));
label("$O$",O,-Z+Y,red);
\end{asypicture}
\end{document}


• +1: Do you personally use asymptote regularly and would you recommend using it? – Dr. Manuel Kuehner Nov 20 '18 at 10:42
• @Dr.ManuelKuehner I use it and do absolutely recommend using it. – user121799 Nov 20 '18 at 12:30