Samuel Ireson

Learning TikZ - Episode 3

Tue Feb 27 2024
2 min read

We'll walk through how I made a figure to visualise locally Euclidean spaces in TikZ.

Contents

Setup

The minimal setup for creating a TikZ figure is as follows,

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
    % TikZ goes here.
\end{document}

which will output a .pdf file, with minimal dimensions. You can include the graphics generated in a master file with the \includegraphics{} command.

Figure

A topological space which is locally Euclidean is one which up close looks like Euclidean space. Visualisation of these spaces naturally becomes a bit difficult in higher dimensions, so I chose the example of the 2-sphere for this figure.

We start which drawing the 2-sphere, which is achieved fairly easily with a circle and an arc.

\draw (0,0) circle (2);
\draw[dashed] (-2,0) arc[x radius=2, y radius=0.5, start angle=180, end angle=360];

2-sphere

We can give this a label, and draw an open subset of the space using the following,

\node[above left] at (135:2) {$ X $};
\filldraw[dashed, fill=gray!50, fill opacity=0.5] plot[smooth cycle] coordinates {(150:1) (30:1) (70:1.5) (110:1.5)};
\node[right] at (70:1.5) {$ U_x $};

2-sphere with open set

Note that we’ve used a different coordinate system here; polar coordinates. These are very useful, and can massively reduce painful computations associated with the Cartesian system. We now use another important TikZ technique; using a scope environment to shift a portion of the figure, while keeping the coordinate system centred on the middle of the portion. Maybe this seems a bit abstract, and an example is probably useful.

We can draw axes for the complex plane, and an open subset within using the following code, wrapping everything in a scope environment and shifting down by 5cm.

\begin{scope}[yshift=-5cm]
    \draw[->] (-2,0) to (2,0);
    \draw[->] (0,-2) to (0,2);
    \node at (-2,2) {$ \mathbb{C} $};

    \filldraw[dashed, fill=gray!50, fill opacity=0.5] plot[smooth cycle] coordinates {(-1.2,-1.2) (1.2,-1.2) (1.2,1.2) (-1.2,1.2)};
    \node[above right] at (1.2,1.2) {$ \tilde{U}_{x} $};
\end{scope}

Coordinate space below

To finish the diagram, we need an arrow to represent the homeomorphism between these two open sets. In order to draw this arrow, we label points in each part of the diagram with nodes,

\node (t) at (150:1) {};

in the top portion, and,

\node (b) at (-1,1.4) {};

in the bottom (scope environment) portion. We can then draw the arrow with,

\draw[->, bend right] (t) to node[left]{$ \phi_x $} (b);

to achieve the final figure,

Finished figure

Conclusion

This is the most complicated figure we’ve drawn so far, but there’s much more left to come. We’ve introduced many of the important techniques in TikZ, and these are applicable in all kinds of different circumstances.

Related posts