Skip to main content

Python interface to generate (readable) Tikz figures.

Project description

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 two nodes connected by an arrow, see Figure 1.

from tikzfigure import TikzFigure

fig = TikzFigure()

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

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

fig.show()

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

print(fig)
% --------------------------------------------- %
% Tikzfigure generated by tikzfigure v0.1.4     %
% https://github.com/max-models/tikzfigure      %
% --------------------------------------------- %
\begin{tikzpicture}
    \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);
\end{tikzpicture}

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

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tikzfigure-0.2.0.tar.gz (57.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tikzfigure-0.2.0-py3-none-any.whl (74.9 kB view details)

Uploaded Python 3

File details

Details for the file tikzfigure-0.2.0.tar.gz.

File metadata

  • Download URL: tikzfigure-0.2.0.tar.gz
  • Upload date:
  • Size: 57.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tikzfigure-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bfb8943a54ea2fdeff2e7598120646392a7a68b12fddf8b0c71fdee78df4020f
MD5 f7ff6039b4535067bdc7decffad2f74c
BLAKE2b-256 f4a361ae63f04c3596d89b162f123a66d5469e931d231a31e772150fd52e0692

See more details on using hashes here.

Provenance

The following attestation bundles were made for tikzfigure-0.2.0.tar.gz:

Publisher: publish_pypi.yml on max-models/tikzfigure

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tikzfigure-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: tikzfigure-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 74.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tikzfigure-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77a6092815b18c6901d6407f520801a0d569b1422cb79b9f14cec208a22520bf
MD5 b5ac48a63592ecf71333526e5fce6698
BLAKE2b-256 3c561ea65cf72239a6080275cff7a38589d2b33e7e573b61d841e0ad77146dc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for tikzfigure-0.2.0-py3-none-any.whl:

Publisher: publish_pypi.yml on max-models/tikzfigure

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page