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

\usepackage{tikz, pgfplots}

    \begin{axis}[hide axis, colormap/bone]
        \addplot3[surf, samples=10] {x^2+y^2};

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.

enter image description here


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}
% from https://tex.stackexchange.com/a/39282/121799
  mark=at position #1 with {\arrow{>};
  \node[font=\sffamily,yshift=7pt] {C};}}}}}
\begin{tikzpicture}[declare function={f(\x,\y)=\x*\x+\y*\y;}]
    \begin{axis}[hide axis, colormap/bone]
        \addplot3[mesh,domain=-5.02:5.02,thick,color=red,samples=10] (-5.02,x,{f(-5.02,x)});
        \addplot3[surf,samples=10,domain=-5:5,domain y=-5:5] {f(x,y)};
        \addplot3[mesh,domain=-5.02:5.02,thick,color=red,samples=10] (5.02,x,{f(5.02,x)});
        \addplot3[domain=-1:5,domain y=-5:-2,
orange,thick,-stealth,samples=6,samples y=4,
    scale arrows=-0.4,
] {f(x,y)};
        \addplot3[mesh,domain=-5.02:5.02,thick,color=red,samples=10] (x,-5.02,{f(x,-5.02)});
        \draw[thick,red,>=stealth,->-=0.5] plot[domain=-5.02:5.02,variable=\x,samples=10] 

enter image description here

You may add additional single arrows along the lines of this answer.

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

import graph3;


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



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



enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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