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.1.tar.gz (71.9 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.1-py3-none-any.whl (90.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tikzfigure-0.2.1.tar.gz
  • Upload date:
  • Size: 71.9 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.1.tar.gz
Algorithm Hash digest
SHA256 f4e7185a748a50f069fb0877aa497c4a33e2d6916a3995bae1ef64f124187bbb
MD5 a6d1603943013ec3d26401b17ba4c0fe
BLAKE2b-256 7b701edcc497250d702f967012a649af316654cca9c919637e82ebb149b13a7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tikzfigure-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: tikzfigure-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 90.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 000c966335b721af17637b1501b04e0ac20ea7f8d66693ba269047101cc04b6a
MD5 ad6cc6779e2cb26921464cd64c63aec0
BLAKE2b-256 c6e11906de856dc8afff8b5420c984d9a009c21c2cf1032b96c71b77aebc731b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tikzfigure-0.2.1-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