A Matplotlib-like interface for generating Tikz and Pgfplots figures
Project description
Generate beautiful, publication-ready figures with the power of Tikz and pgfplots, with a comfortable, familiar Python syntax.
pykz aims to provide a syntax similar to matplotlib, but with the possibility of directly generating (and controlling!) your tikz code.
The benefit over alternatives like tikzplotlib is that pykz was designed explicitly with pgfplots in mind, whereas the goal of tikzplotlib is to map matplotlib concepts to pgfplots. The latter is arguably more convenient if you already have code for matplotlib, but it often still requires manual tweaking to the resulting tex-files. pykz aims to provide more control over the final output directly in Python, so no manual tweaking is required afterwards.
Usage
Basic plotting
Pykz has a simple, matplotlib-like interface for basic plotting.
import numpy as np
import pykz
x = np.linspace(0, 10, 100)
y = np.sin(x)
pykz.plot(x, y)
# (Optional) save the tikz code to a file.
pykz.save("test-basic-plot.tex")
# Save the Tikz code to a temporary file, compile it, and open the pdf in the default viewer.
pykz.preview()
Using Tikz primitives
Alternatively, you can use standard TikZ drawing primitives, without using pfgplots. Options passed to the TikZ command are passed as keyword arguments.
import pykz
rect = pykz.rectangle((-1, -1), (1, 1))
circle = pykz.circle((2, 0), (1), fill="red")
rect2 = pykz.rectangle((1, 1), (2, 3), fill="cyan")
# Dump the generated tikz code to the stdout.
print(pykz.dumps())
# Save the Tikz code to a temporary file, compile it, and open the pdf in the default viewer.
pykz.preview()
out:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw(-1.000000000, -1.000000000) rectangle (1.000000000, 1.000000000);
\draw[fill=red](2.000000000, 0.000000000) circle (1);
\draw[fill=cyan](1.000000000, 1.000000000) rectangle (2.000000000, 3.000000000);
\end{tikzpicture}
\end{document}
More examples can be found in the online documentation.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pykz-0.1.4.tar.gz.
File metadata
- Download URL: pykz-0.1.4.tar.gz
- Upload date:
- Size: 28.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b171e9aec559347222ddc85e6f7995441fd01a76156fad3a05e670934fe2fb28
|
|
| MD5 |
a07367f65b86acdfe5b61bba6a1b7b29
|
|
| BLAKE2b-256 |
7da675927b4e637c975b5a68d94396b9d3ebe37696cab0ead626d856c7670134
|
Provenance
The following attestation bundles were made for pykz-0.1.4.tar.gz:
Publisher:
wheels.yaml on Mathijssch/pykz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pykz-0.1.4.tar.gz -
Subject digest:
b171e9aec559347222ddc85e6f7995441fd01a76156fad3a05e670934fe2fb28 - Sigstore transparency entry: 168256474
- Sigstore integration time:
-
Permalink:
Mathijssch/pykz@b04bb3527f8f50ce85b999d27e4d83bdea173f8a -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/Mathijssch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yaml@b04bb3527f8f50ce85b999d27e4d83bdea173f8a -
Trigger Event:
release
-
Statement type:
File details
Details for the file pykz-0.1.4-py3-none-any.whl.
File metadata
- Download URL: pykz-0.1.4-py3-none-any.whl
- Upload date:
- Size: 34.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32a87e5513fafa14e47ea2d9e6de515dae6a68bbfdb1f14ad9d020200a28a98f
|
|
| MD5 |
8af5b8bd8e43342579ec15052b670bf6
|
|
| BLAKE2b-256 |
61545c341f741862c0529be3f8939c5bb9151f1f865c9335c2b0d6ad3ff6c768
|
Provenance
The following attestation bundles were made for pykz-0.1.4-py3-none-any.whl:
Publisher:
wheels.yaml on Mathijssch/pykz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pykz-0.1.4-py3-none-any.whl -
Subject digest:
32a87e5513fafa14e47ea2d9e6de515dae6a68bbfdb1f14ad9d020200a28a98f - Sigstore transparency entry: 168256475
- Sigstore integration time:
-
Permalink:
Mathijssch/pykz@b04bb3527f8f50ce85b999d27e4d83bdea173f8a -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/Mathijssch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yaml@b04bb3527f8f50ce85b999d27e4d83bdea173f8a -
Trigger Event:
release
-
Statement type: