Skip to main content

tikzfigure

Python interface to generate (readable) Tikz figures.

Install

Create and activate python environment, then install tikzfigure with

pip install tikzfigure

Examples

Generate tikz-figures with Python API

Generate a simple TikZ figure with nodes and arrows, see Figure 1.

from tikzfigure import TikzFigure

fig = TikzFigure()

n1 = fig.node(x=0, y=0, shape="circle", fill="blue!40!green", content="Tikz")
n2 = fig.node(x=2, y=0, shape="circle", fill="purple!40!orange", content="Figure")

fig.draw([n1, n2], line_width=2, arrows="->", color="gray")

fig.variable("R", 1.0)

with fig.loop("angle", range(40, 340, 20)) as loop:
    loop.node(
        x=r"\R*cos(\angle)",
        y=r"\R*sin(\angle)",
        shape="circle",
        fill="red!50",
    )

fig.show()

For segment-local TikZ options, you can also build paths fluently with Node.to(...) and keep path-wide styling on fig.draw(...).

You can also save the figure as a .tikz file or print the LaTeX code:

print(fig)
% --------------------------------------------- %
% Tikzfigure generated by tikzfigure v0.2.1     %
% https://github.com/max-models/tikzfigure      %
% --------------------------------------------- %
\begin{tikzpicture}
    \pgfmathsetmacro{\R}{1.0}
    \node[shape=circle, fill=blue!40!green] (node0) at ({0}, {0}) {Tikz};
    \node[shape=circle, fill=purple!40!orange] (node1) at ({2}, {0}) {Figure};
    \draw[color=gray, line width=2, arrows=->] (node0) to (node1);
    \foreach \angle in {40,60,80,100,120,140,160,180,200,220,240,260,280,300,320}{
        \node[shape=circle, fill=red!50] () at ({\R*cos(\angle)}, {\R*sin(\angle)}) {};
    }
\end{tikzpicture}

Note that to visualize the plots in a popup or in jupyterlab, install with pip install "tikzfigure[vis]"

Drawing without creating a figure

For quick scripts and notebooks you can skip the TikzFigure object altogether. The module-level functions draw on an implicit current figure that is created the first time you use one, much like matplotlib.pyplot:

import tikzfigure as tf

tf.draw([(0, 0), (1, 1), (2, 0)], arrows="->")
tf.circle((1, 1), radius=0.3, fill="cyan!40")
tf.show()

Use tf.figure() to start a new figure, tf.gcf() to get hold of the current one, tf.scf(fig) to make an existing figure current, and tf.close() to throw the current figure away. Anything you can do on a TikzFigure is available as a module-level function.

The explicit API remains the recommended one for larger figures, since it is the only way to work on several figures at once.

IPython Magic Commands

tikzfigure includes IPython magic commands for compiling TikZ figures directly in Jupyter notebooks!

Load the extension:

%load_ext tikzfigure.ipython

Then use the %%tikz cell magic:

%%tikz
\begin{tikzpicture}
\draw[thick, blue] (0,0) circle (2cm);
\node at (0,0) {Hello TikZ!};
\end{tikzpicture}

See tutorials for more examples!

Metadata

Release files for tikzfigure 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tikzfigure 0.5.0
File Size Uploaded
tikzfigure-0.5.0.tar.gz 199.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tikzfigure 0.5.0
File Interpreter ABI Platform
tikzfigure-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 441.1 kB

Release files / tikzfigure-0.5.0.tar.gz

Download URL tikzfigure-0.5.0.tar.gz
Size 199.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1b79fd8334a173353d8733d4c53334bdf6098705280ea9aae43e451be5e833bc
BLAKE2b-256 checksum
How to use checksums
2955b9cd0f7f26df8e89621a07884dcd889fbec46509821e0dff64f92421a670
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / tikzfigure-0.5.0-py3-none-any.whl

Download URL tikzfigure-0.5.0-py3-none-any.whl
Size 241.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ec195f90fef0f107b6fe90a2e1517b2d09e43ff28b12d162ede78f53d021a9b
BLAKE2b-256 checksum
How to use checksums
ab734047f008aff2a4b7f26e4324a373d1d453f45b3826a6f349c00d239eadd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page