7

I'm working on creating an illustration that I will need in many, different guises in differential geometry/manifold theory etc. Following on from a previous (answered) question of mine (How can I make an arrow from a point in one axis to a point in another?, I want to show how two coordinate lines in the plane originate from two curves on a surface via the chosen map:

\begin{tikzpicture}
    \begin{axis}[
            name=mfd,
            declare function={
                    f(\x,\y)=10-(\x^2+\y^2);
            },      
            declare function={
                    c_x(\t)=(cos(\t)+(sin(5*\t)/10))/3+1;
            },      
            declare function={
                    c_y(\t)=(sin(\t))/2-1;
            },      
            declare function={
                    c_z(\t)=f(c_x(\t),c_y(\t));
            },      
    ]       
            \addplot3[surf,domain=-2:2,domain y=-2:2,]{f(x,y)};
            \addplot3[black,opacity=1.0,variable=t,domain=0:360,dashed,thin] ({c_x(t)},{c_y(t)},{c_z(t)});
            \addplot3[black,opacity=1.0,variable=t,domain=-2:2,thin] (t,-1.2,{f(t,-1.2)});
            \addplot3[black,opacity=1.0,variable=t,domain=-2:2,thin] (0.8,t,{f(t,-1.2)});
            \addplot3[black,opacity=1.0,only marks,mark=text,text mark=$\cdot$] (1,-1,{f(1,-1)}) coordinate (a);
    \end{axis}
    \begin{axis}[
            at={($(mfd.north east)+(1cm,-2cm)$)},
            anchor=north west,
            declare function={
                    c_x(\t)=(cos(\t)+(sin(5*\t)/10))/3+1;
            },      
            declare function={
                    c_y(\t)=(sin(\t))/2-1;
            }       
    ]       
            \addplot[variable=t,domain=0:360]({c_x(t)},{c_y(t)});
            \addplot[black,opacity=1.0,only marks,mark=text,text mark=$\cdot$] (1,-1) coordinate (b);
            \addplot[variable=t,domain=0.6:1.4](t,-1.2);
            \addplot[variable=t,domain=-1.5:-0.5](0.8,t);
    \end{axis}
    \draw [-stealth, shorten <= 3pt, shorten >= 3pt] (a) to[bend left] (b);
\end{tikzpicture}

However, I have a couple of problems:

  • The curves representing the coordinate axes pulled back from the plane via the coordinate map insist on being closed off with a straight line - is there a way to avoid that?
  • I want to draw all the black curves with a thin, dashed line, but I probably don't understand how to set those options. What am I doing wrong?

I apologise if these questions are rather elementary, but I find the relevant manuals difficult to search through; they seem to be meant for reading cover to cover rather than reference.

  • thin,dashed makes it what you'd think. Use very thin or ultra thin to get it thinner. – Torbjørn T. Aug 30 '17 at 21:37
  • Setting the line width to 0pt is actually 1 pixel wide (whatever 1 pixel is on the display device). – John Kormylo Aug 31 '17 at 1:34
  • well, it doesn't seem to work in this case: – j4nd3r53n Aug 31 '17 at 8:34
  • oops, ran into a silly time limit before I had finished my comment: well, it doesn't seem to work in this case: "\addplot3[black,opacity=1.0,variable=t,domain=0:360,dashed,thin] ({c_x(t)},{c_y(t)},{c_z(t)});" (from my code snippet above) – j4nd3r53n Aug 31 '17 at 8:50
  • Hm, yes, I see that now, sorry. Odd. (By the way, I'd forgotten that thin is actually the default line width, so use e.g. very thin to make it thinner than default.) – Torbjørn T. Aug 31 '17 at 14:11
6

The reason for the problem, I think, can be found in this quote from the pgfplots manual:

If there is no value for neither mesh/rows nor mesh/cols or if one of them is 1, pgfplots will draw a line plot. [...]

For \addplot3 expression, this requires to set samples y=0 to disable the generation of a mesh.

(Emphasis mine.) Note that samples y=1 will also work, and the manual says this at another point:

If you use \addplot3 expression, mesh/rows and mesh/cols are computed from the values samples and samples y. By default, \addplot3 expression always samples a mesh. If you want it to sample a line, set samples y=1 (or, equivalently, y domain=0:0).

(Again, emphasis mine. I don't know the technical differences between the two.)

Seems line specifications didn't work for a mesh, and the mesh is also the reason you got closed curves. Hence, if you set samples y=0 for your black lines, it works as expected. I did that via a style, in the example below.

I actually made three different styles, one for the point, one for the coordinate lines, one for the shape, one for the point. You also had the wrong z-coordinate for the second coordinate line, it should be f(0.8,t) not f(t,-1.2).

For the annotations, you can use relative coordinates. Say you have a saved coordinate c, you can do something like

\draw [stealth-] (c) to[bend left] ++(2cm,1cm) node[right] {...};

This puts the arrow tip at the start of the path, and the node at the end is placed at right of the end of the path. This saves you absolute coordinates, and also having to reuse those in the \node.

I also modified some of the math, notably use \dim instead of dim, and e.g. $...$ for $...$ instead of $... \ for\ ...$.

output of code

\documentclass{article} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{diagrams}
\usepackage[document]{ragged2e}
\usepackage{wasysym}
\usepackage{tensor}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\tikzset{
  myarrow/.style={stealth-,shorten >=3pt,shorten <=3pt}
}
\pgfplotsset{
  lineplot/.style={
    black,
    dashed,
    very thin,
    samples y=0
  },
  coordinate line/.style={
    black,
    samples y=0
  },
  point/.style={
    only marks,
    mark=*,
    black,
    mark size=0.5pt
  }
}
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[section]


\begin{document}
    \begin{theorem}
        Let $\mathbf{M}$ be a smooth manifold and $p \in \mathbf{M}$; then $\dim(\mathbf{T_pM}) = dim(\mathbf{M})$
    \end{theorem}
    \begin{proof}
        To prove this, we construct a vector space basis for $\mathbf{T_pM}$ from a chart. Choose a chart $(U,x), with \  p \in U$. Consider $\dim(\mathbf{M})$ curves $\gamma_{(a)}$, with   $a = 1, \dots, \dim(\mathbf{M}), \gamma_{(a)} \colon \mathbb{R} \rightarrow U$, so that $(x^b \circ \gamma_{(a)}) (\lambda) = \delta^b_a \cdot \lambda$ for some $\lambda \in \mathbb{R}$ -- like this:

        \begin{tikzpicture}
            \begin{axis}[
                name=mfd,
                axis lines=none,
                declare function={
                    f(\x,\y)=10-(\x^2+\y^2);
                },
                declare function={
                    c_x(\t)=(cos(\t)+(sin(5*\t)/10))/3+1;
                },
                declare function={
                    c_y(\t)=(sin(\t))/2-1;
                },
                declare function={
                    c_z(\t)=f(c_x(\t),c_y(\t));
                },
                declare function={
                    x_0(\t)=-1.2;
                },
                declare function={
                    x_1(\t)=0.8;
                }
            ]
                \addplot3[surf,domain=0:2,domain y=-2:0,]{f(x,y)};
                \addplot3[lineplot,variable=t,domain=0:360] ({c_x(t)},{c_y(t)},{c_z(t)});
                \addplot3[coordinate line,variable=t,domain=0:2] (t,{x_0(t)},{f(t,{x_0(t)})});
                \addplot3[coordinate line,variable=t,domain=-2:0] ({x_1(t)},t,{f({x_1(t)},t)});
                \addplot3[point] (1,-1,{f(1,-1)}) coordinate (a);
                \addplot3[point](.5,{x_0(.5)},{f(.5,{x_0(.5)})}) coordinate (x_dot);
                \addplot3[point]({x_1(-.5)},-.5,{f({x_1(-.5)},-.5)}) coordinate (y_dot);
            \end{axis}
            \draw [myarrow]  (x_dot) to[bend left] ++(-2cm,-4cm) node[below] {$\gamma_{(0)}$};
            \draw [myarrow]  (y_dot) to[bend right] ++(2cm,0.5cm) node [right] {$\gamma_{(1)}$};
            \begin{axis}[
                at={($(mfd.north east)+(1cm,-2cm)$)},
                anchor=north west,
                axis lines=none,
                declare function={
                    c_x(\t)=(cos(\t)+(sin(5*\t)/10))/3+1;
                },
                declare function={
                    c_y(\t)=(sin(\t))/2-1;
                },
                declare function={
                    x_0(\t)=-1.2;
                },
                declare function={
                    x_1(\t)=0.8;
                }
            ]
                \addplot[lineplot,variable=t,domain=0:360]({c_x(t)},{c_y(t)});
                \addplot[point] (1,-1) coordinate (b);
                \addplot[coordinate line,variable=t,domain=0.6:1.4](t,{x_0(t)});
                \addplot[coordinate line,variable=t,domain=-1.5:-0.5]({x_1(t)},t);
                \addplot[point](.8,-.5) coordinate (P1);
                \addplot[point](.6,-1.2) coordinate (P2);
            \end{axis}
            \draw [myarrow] (b) to[bend right] node [above=7pt] {$x$} (a);
            \draw [myarrow] (P1) to[bend left] ++(-1cm,1cm) node[above] {$(x \circ \gamma_{(1)})$};
            \draw [myarrow] (P2) to[bend left] ++(-3cm,-1cm) node[above] {$(x \circ \gamma_{(0)})$};
        \end{tikzpicture}

        Given $p \in \mathbf{M}$, choose a chart $(U,x)$, so that $x(p)=0_{\mathbb{R}^{\dim M}}$, and curves $\gamma_{(a)}$, with $p = \gamma_{(a)}(0)$, for $a = 1, \dots, \dim M$:
        \begin{align*}
            e_a &:= X_{\gamma_{(a)},p}, a = 1, \dots, \dim M \\
            e_a f &= X_{\gamma_{(a)},p} f \\
            &=(f \circ \gamma_{(a)})' (0) \\
            &= (f \circ x^{-1} \circ x \circ \gamma_{(a)})' (0) \\
            &= \partial_b (f \circ x^{-1}) \cdot (x(\gamma_{(a)}(0))) \cdot (x^b \circ \gamma_{(a)})' (0) \\
            &= \partial_b (f \circ x^{-1})(x(p)) \cdot \delta^b_a \\
            &= \partial_a (f \circ x^{-1})
        \end{align*}
        (to be continued ...)
    \end{proof}
\end{document}
  • That's great - I had, finally, stumbled over the 'samples y=0' to get rid of the unwanted closure of the coordinate curves, but I hadn't got as far as the styles. I will massage it a bit more and publish the result as an answer below - it might be of interest to others. – j4nd3r53n Sep 1 '17 at 8:21
  • @j4nd3r53n I updated my answer, so show a slightly different way of making those annotation arrows, using relative coordinates as opposed to explicit ones. – Torbjørn T. Sep 1 '17 at 9:47
  • Torbjørn - we're not supposed to say "thanks", but thanks. Your edits make a lot of sense. Great stuff. – j4nd3r53n Sep 1 '17 at 13:37
  • @j4nd3r53n You're welcome. (Personally, I think the whole "don't say thanks"-thing is a bit silly.) – Torbjørn T. Sep 1 '17 at 13:38
1

As promised, here is a bit of context for this illustration - it is part of a proof, so I have included some of the fluff around the picture:

\documentclass{article} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{diagrams}
\usepackage[document]{ragged2e}
\usepackage{wasysym}
\usepackage{tensor}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\pgfplotsset{
  lineplot/.style={
    black,
    dashed,
    very thin,
    samples y=0
  },
  coordinate line/.style={
    black,
    samples y=0
  },
  point/.style={
    only marks,
    mark=*,
    black,
    mark size=0.5pt
  }
}
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[section]

\begin{document}
    \begin{theorem}
        Let $\mathbf{M}$ be a smooth manifold and $p \in \mathbf{M}$; then $dim(\mathbf{T_pM}) = dim(\mathbf{M})$
    \end{theorem}
    \begin{proof}
        To prove this, we construct a vector space basis for $\mathbf{T_pM}$ from a chart. Choose a chart $(U,x), with \  p \in U$. Consider $dim(\mathbf{M})$ curves $\gamma_{(a)}, with \  a = 1, \dots, dim(\mathbf{M}), \gamma_{(a)} \colon \mathbb{R} \rightarrow U$, so that $(x^b \circ \gamma_{(a)}) (\lambda) = \delta^b_a \cdot \lambda$ for some $\lambda \in \mathbb{R}$ - like this:\linebreak
        \begin{tikzpicture}
            \begin{axis}[
                name=mfd,
                axis lines=none,
                declare function={
                    f(\x,\y)=10-(\x^2+\y^2);
                },
                declare function={
                    c_x(\t)=(cos(\t)+(sin(5*\t)/10))/3+1;
                },
                declare function={
                    c_y(\t)=(sin(\t))/2-1;
                },
                declare function={
                    c_z(\t)=f(c_x(\t),c_y(\t));
                },
                declare function={
                    x_0(\t)=-1.2;
                },
                declare function={
                    x_1(\t)=0.8;
                }
            ]
                \addplot3[surf,domain=0:2,domain y=-2:0,]{f(x,y)};
                \addplot3[lineplot,variable=t,domain=0:360] ({c_x(t)},{c_y(t)},{c_z(t)});
                \addplot3[coordinate line,variable=t,domain=0:2] (t,{x_0(t)},{f(t,{x_0(t)})});
                \addplot3[coordinate line,variable=t,domain=-2:0] ({x_1(t)},t,{f({x_1(t)},t)});
                \addplot3[point] (1,-1,{f(1,-1)}) coordinate (a);
                \addplot3[point](.5,{x_0(.5)},{f(.5,{x_0(.5)})}) coordinate (x_dot);
                \addplot3[point]({x_1(-.5)},-.5,{f({x_1(-.5)},-.5)}) coordinate (y_dot);
            \end{axis}
            \draw [-stealth, shorten <= 3pt, shorten >= 3pt] (.5,-.5) to[bend right] (x_dot);
            \node[below] at (.5,-.5) {$\gamma_{(0)}$};
            \draw [-stealth, shorten <= 3pt, shorten >= 3pt] (5,5) to[bend left] (y_dot);
            \node[right] at (5,5) {$\gamma_{(1)}$};
            \begin{axis}[
                at={($(mfd.north east)+(1cm,-2cm)$)},
                anchor=north west,
                axis lines=none,
                declare function={
                    c_x(\t)=(cos(\t)+(sin(5*\t)/10))/3+1;
                },
                declare function={
                    c_y(\t)=(sin(\t))/2-1;
                },
                declare function={
                    x_0(\t)=-1.2;
                },
                declare function={
                    x_1(\t)=0.8;
                }
            ]
                \addplot[lineplot,variable=t,domain=0:360]({c_x(t)},{c_y(t)});
                \addplot[black,opacity=1.0,only marks,mark=text,text mark=$\cdot$] (1,-1) coordinate (b);
                \addplot[coordinate line,variable=t,domain=0.6:1.4](t,{x_0(t)});
                \addplot[coordinate line,variable=t,domain=-1.5:-0.5]({x_1(t)},t);
                \addplot[point](.8,-.5) coordinate (P1);
                \addplot[point](.6,-1.2) coordinate (P2);
            \end{axis}
            \draw [-stealth, shorten <= 3pt, shorten >= 3pt] (a) to[bend left] node [above=7pt] {$x$} (b);
            \draw [-stealth, shorten <= 3pt, shorten >= 3pt] (9,4) to[bend right] (P1);
            \node[above] at (9,4) {$(x \circ \gamma_{(1)})$};
            \draw [-stealth, shorten <= 3pt, shorten >= 3pt] (5,-1) to[bend right] (P2);
            \node[above] at (5,-1) {$(x \circ \gamma_{(0)})$};
        \end{tikzpicture}
        Given $p \in \mathbf{M}$, choose a chart $(U,x)$, so that $x(p)=0_{\mathbb{R}^{dim M}}$, and curves $\gamma_{(a)}, with \  p = \gamma_{(a)}(0), for \ a = 1, \dots, dim M$:
        \begin{align*}
            e_a &:= X_{\gamma_{(a)},p}, a = 1, \dots, dim M \\
            e_a f &= X_{\gamma_{(a)},p} f \\
            &=(f \circ \gamma_{(a)})' (0) \\
            &= (f \circ x^{-1} \circ x \circ \gamma_{(a)})' (0) \\
            &= \partial_b (f \circ x^{-1}) \cdot (x(\gamma_{(a)}(0))) \cdot (x^b \circ \gamma_{(a)})' (0) \\
            &= \partial_b (f \circ x^{-1})(x(p)) \cdot \delta^b_a \\
            &= \partial_a (f \circ x^{-1})
        \end{align*}
        (to be continued ...)
    \end{proof}
\end{document}

There are still some loose ends - I'm not quite happy about the way I have had to use explicit coordinates for the arrows and their labels; it doesn't seem elegant, and there must be a better way. Also, there are visible blobs on the coordinate curves because of the way I placed a point there to have an end point for my arrows. Still, I hope it is useful for people.

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.