# TikZ examples: 179 figures with code, by field

> A gallery of 179 TikZ and pgfplots figures with their full code, from open-source collections (MIT or CC0): physics, maths, machine learning, plots, diagrams.

URL: https://www.labcanvas.com/tikz/examples

Updated 2026-11-22.

## Quick answer

Here are 179 TikZ figures with their complete code, in 11 fields: physics, chemistry, biology, machine learning, mathematics, electronics and signals, computer science, plots and charts, diagrams, commutative diagrams, and colour and shading. They come from open-source collections whose licences allow any use (MIT or CC0), and each figure keeps its author, source and licence. Open any of them in the TikZ editor to change it, or copy its code into your own document.

## Browse by field

Each field has its own page with all of its figures, grouped by topic:

## A few figures from each field

“Open in the TikZ editor” loads the figure’s whole document, with its source and licence, into the free TikZ editor, where it is typeset with TeX Live 2026 as you change it. The licence link goes to the licence’s full text; the repository link goes to the original file.

- [TikZ physics examples](https://www.labcanvas.com/tikz/examples/physics) (18 figures): Bloch sphere, Scattering and detailed balance, Bose–Einstein distribution (3D), Critical temperature curves, Gas pressure on a wall, Ideal and van der Waals isotherms, Maxwell–Boltzmann speed distribution, Otto cycle (p–V diagram), Spontaneous magnetisation, Thomson scattering, Helicopter free-body diagram, k-space lattice of states, Seebeck effect (thermoelectric), Basis plus lattice equals crystal, Ferroelectric response, Feynman diagram with a loop, M-theory and its limits, RG flow in theory space.
- [TikZ chemistry examples](https://www.labcanvas.com/tikz/examples/chemistry) (6 figures): Ball-and-stick organic molecule, Wyckoff positions, Convex hull of stability, Kohn–Sham self-consistency cycle, Sabatier principle (volcano plot), Choices in a DFT calculation.
- [TikZ biology examples](https://www.labcanvas.com/tikz/examples/biology) (5 figures): DNA double helix, Gene expression: transcription and translation, Progressive sequence alignment, De Bruijn graph, Multiplex epidemics–awareness network.
- [TikZ neural network and machine learning examples](https://www.labcanvas.com/tikz/examples/machine-learning) (56 figures): Skip (residual) connection, Deep belief network, Multilayer perceptron, Relational network, Activation functions, Artificial neuron, Perceptron network for XOR, Self-organising map, Fully connected network, Single neuron, Encoder–decoder template, Neural network template, 2D convolution, Convolutional autoencoder, À trous (dilated) convolutions, Cross-modal CNN (X-CNN), Max pooling, Convolution layer, VGG-16 architecture, ResNet block, Bidirectional LSTM, LSTM cell, GRU cell, LSTM cell (detailed), Backpropagation through time, RNN encoder–decoder, Self-attention, Attention over encoder states, Scaled dot-product attention, Transformer (encoder–decoder), Encoder-only transformer, LoRA fine-tuning, FlashAttention, MADE: masked autoencoder, CycleGAN, Generative adversarial network, Variational denoising autoencoder, GAN overview, Deep Graph Infomax, Graph attention (GAT) layer, Graph convolution, Message passing neural network, Regular vs Bayesian neural network, Restricted Boltzmann machine, Markov random field for segmentation, Hidden Markov model, Bayesian graphical model (plate notation), Random forest, Dropout, Reinforcement learning: greedy policy, Semi-supervised learning, Supervised learning setup, Overfitting: training vs validation error, Bias–variance trade-off, Learning curve, Backpropagation through a node.
- [TikZ mathematics examples](https://www.labcanvas.com/tikz/examples/mathematics) (36 figures): Fundamental domain of the modular group, Cylinder to plane (conformal map), Unit circle: sine and cosine, Arbelos, Incircle and circumcircle, Koch snowflake, Manhattan distance, Pair of pants, Hamiltonian cycle, Web graph, Complete bipartite graph K3,3, Königsberg bridges, Branch cuts in the complex plane, Saddle point surface, Taylor polynomials of sine, Area under x² (integral), Vector addition and scaling, Highlighting matrix entries, CP tensor factorisation, Third-order tensor, Circulant matrix product, ℓ1 norm unit ball, ℓ2 norm unit ball, Tensor mode-3 product, Bayes’ theorem, geometrically, Markov chain (rain and sun), Two normal distributions, Normal distribution: rejection regions, Student’s t vs normal distribution, Log-normal distribution, Kalman filter, Polynomial interpolation (Runge), Conjugate gradient steps, Fluid domain with boundary, Q1 finite element basis function, Five-point stencil on a grid.
- [TikZ electronics and signal examples](https://www.labcanvas.com/tikz/examples/electronics-and-signals) (7 figures): MOSFET cross-section, CMOS NOR gate, CMOS SRAM cell, Amplitude modulation, Frequency modulation, Signal sampling, IQ sampling.
- [TikZ computer science examples](https://www.labcanvas.com/tikz/examples/computer-science) (12 figures): Binary search tree, Red–black tree, Binary heap, Singly linked list, Burrows–Wheeler transform, Maximum flow problem, Shortest path in a weighted graph, Fetch–decode–execute cycle, Git workflow, IEEE 754 floating-point number, System block diagram, Virtual machines vs containers.
- [TikZ and pgfplots chart examples](https://www.labcanvas.com/tikz/examples/plots-and-charts) (16 figures): Intersection of two curves, Filling between curves, Spiral in polar axes, 3D bar plot, Colour-blind-friendly mesh plot, Surface plot (viridis), Bar chart with value labels, Pie chart (pgf-pie), Grouped bar chart, Stacked bar chart, Horizontal bar chart, Pie chart (percentages), Stacked bar chart (publications per year), Line chart with annotations, Line chart with markers, Stacked area chart.
- [TikZ diagram examples: flowcharts, mind maps, Venn](https://www.labcanvas.com/tikz/examples/diagrams) (14 figures): Horizontal flowchart, Vertical flowchart, Chevron sequence diagram, Flowchart template, Materials informatics challenges, Circular process diagram, Bubble diagram, Constellation diagram, Descriptive diagram, Priority diagram, Mind map (large), Mind map (medium), Circular tree, Venn diagram with transparency.
- [TikZ commutative diagram examples](https://www.labcanvas.com/tikz/examples/commutative-diagrams) (3 figures): Thermodynamic ensembles and transforms, Commutative diagram: universal property, Tensor product universal property.
- [TikZ colour and shading examples](https://www.labcanvas.com/tikz/examples/colour-and-shading) (6 figures): Colour wheel, Colour triangle, Ball shading, Shaded spiral of segments, Slanted cube, Op-art circles (foreach).

## Where the figures come from

The figures were collected from these open-source repositories, at fixed commits, and kept only if they compile on their own, within ten seconds, in the TeX Live 2026 setup the TikZ editor uses. Collections, figures and files that carried no licence, a share-alike licence, or that were adapted from other people’s work were left out.

LabCanvas changed a file only where it had to compile on its own: the document class became `standalone` where needed, and the repository’s own helper files were copied in. The first lines of each figure’s code say where it comes from, who holds the copyright, which licence applies and what was changed.

| Collection | Copyright holder | Licence | Figures |
| --- | --- | --- | --- |
| [MartinThoma/LaTeX-examples](https://github.com/MartinThoma/LaTeX-examples) | Martin Thoma | MIT licence (https://www.labcanvas.com/tikz-library/credits.html#thoma) | 40 |
| [PetarV-/TikZ](https://github.com/PetarV-/TikZ) | Petar Veličković | MIT licence (https://www.labcanvas.com/tikz-library/credits.html#petarv) | 38 |
| [janosh/diagrams](https://github.com/janosh/diagrams) | Janosh Riebesell and contributors | MIT licence (https://www.labcanvas.com/tikz-library/credits.html#janosh) | 35 |
| [PacktPublishing/LaTeX-graphics-with-TikZ](https://github.com/PacktPublishing/LaTeX-graphics-with-TikZ) | Packt (code from LaTeX Graphics with TikZ by Stefan Kottwitz) | MIT licence (https://www.labcanvas.com/tikz-library/credits.html#packt) | 29 |
| [xinychen/awesome-latex-drawing](https://github.com/xinychen/awesome-latex-drawing) | Xinyu Chen | MIT licence (https://www.labcanvas.com/tikz-library/credits.html#xinychen) | 12 |
| [fraserlove/nntikz](https://github.com/fraserlove/nntikz) | Fraser Love | MIT licence (https://www.labcanvas.com/tikz-library/credits.html#nntikz) | 11 |
| [opentikz/opentikz](https://github.com/opentikz/opentikz) | OpenTikZ contributors | CC0 1.0 (https://www.labcanvas.com/tikz-library/credits.html#opentikz) | 8 |
| [bueler/tikz-examples](https://github.com/bueler/tikz-examples) | Ed Bueler | MIT licence (https://www.labcanvas.com/tikz-library/credits.html#bueler) | 3 |
| [andreas-bauer/tikz](https://github.com/andreas-bauer/tikz) | Andreas Bauer | MIT licence (https://www.labcanvas.com/tikz-library/credits.html#bauer) | 2 |
| [Devin-Taylor/TikZ](https://github.com/Devin-Taylor/TikZ) | Devin Taylor | MIT licence (https://www.labcanvas.com/tikz-library/credits.html#devin) | 1 |

## How to reuse a figure from the gallery

- **Open it in the TikZ editor** (or open the source file from the repository link) and check that it compiles.
- **Keep the first comment lines of the code.** They name the source, the copyright holder and the licence; the MIT licence asks that its copyright and permission notice go with copies of the code.
- **Change what you need**: labels, colours, sizes. Most figures are a single `tikzpicture` in a `standalone` document.
- **Use it in your document**: either compile it on its own and include the PDF with `\includegraphics`, or move its `\usepackage` and `\usetikzlibrary` lines into your preamble and paste the `tikzpicture` where the figure goes.

Some figures were written for older versions of TikZ and load the `arrows` library, which the manual marks as deprecated in favour of `arrows.meta`. They still compile; in new code, prefer `arrows.meta`.

## Frequently asked questions

### Can I use these TikZ examples in my paper or thesis?

Yes. Every figure is under the MIT licence or CC0 1.0, both of which allow use, change and redistribution, commercial use included. For MIT figures, keep the copyright and permission notice with the code (the first lines of each file point to it), and credit the author in your caption as a courtesy.

### Do I need to credit the author?

For CC0 figures, no. For MIT figures, the licence asks that its copyright and permission notice travel with copies of the code; keep the comment lines at the top of the file. Crediting the source in your figure caption is courteous either way.

### Why does an example not compile in my document?

Most figures are standalone documents. When you paste only the tikzpicture into your own file, also copy its \usepackage and \usetikzlibrary lines (and any \pgfplotsset line) into your preamble. A figure marked LuaLaTeX must be compiled with LuaLaTeX.

### Is there a search?

The TikZ editor’s library has a search box over the same figures (titles, topics and sources). Open the [TikZ editor](https://www.labcanvas.com/tools/tikz-editor) and choose Browse the library.

### How were the thumbnails made?

Each thumbnail was rendered from the figure’s code with TeX Live, the same way the TikZ editor renders code.

## References

- [LabCanvas TikZ library: sources and licences (full licence texts)](https://www.labcanvas.com/tikz-library/credits.html)
- [The MIT License (Open Source Initiative)](https://opensource.org/license/mit)
- [CC0 1.0 Universal (Creative Commons)](https://creativecommons.org/publicdomain/zero/1.0/)
- [PGF/TikZ manual (version 3.1.12), §16.1 Arrows: overview (the arrows library is deprecated)](https://tikz.dev/tikz-arrows#sec-16.1)
- [PGF/TikZ manual (version 3.1.12), §42 Arrow Tip Library](https://tikz.dev/library-arrows)
- [standalone class manual (v1.5a), §5.1 Basic usage](https://mirrors.ctan.org/macros/latex/contrib/standalone/standalone.pdf)

## More TikZ guides

- [TikZ: what it is and how to use it in LaTeX](https://www.labcanvas.com/tikz): What TikZ (PGF/TikZ) is and how to use it in LaTeX: the minimal document, libraries, coordinates, a first figure in steps, Overleaf and TeX Live.
- [The tikzpicture environment: options, scaling and centring](https://www.labcanvas.com/tikz/tikzpicture): The tikzpicture environment: its options, scale vs transform shape vs \resizebox, centring it in a figure with a caption, and inline TikZ with baseline.
- [The PGF/TikZ manual: where to find it and which part to read](https://www.labcanvas.com/tikz/manual): Where the official PGF/TikZ manual is (CTAN PDF, texdoc tikz, the tikz.dev HTML edition), which version it describes, and which section to read for each task.
- [Commutative diagrams with tikz-cd](https://www.labcanvas.com/tikz/commutative-diagrams): Draw commutative diagrams with tikz-cd: the tikzcd grid, \arrow directions, labels, arrow styles, pullbacks, exact sequences, snake lemma and editors.
- [CircuiTikZ: drawing circuits in LaTeX](https://www.labcanvas.com/tikz/circuitikz): Draw circuits in LaTeX with CircuiTikZ 1.8.7: the to[R=$R_1$] syntax, sources, switches, labels, ground, op-amps, transistors, logic gates, full examples.
- [TikZ arrows: arrow tips, sizes, curves and labels](https://www.labcanvas.com/tikz/arrows): All TikZ arrow tips in one rendered table, arrows.meta sizing (length, width, scale, open, round), and curved, labelled, thick, block and squiggly arrows.
