Metadata-Version: 2.3
Name: pykz
Version: 0.1.4
Summary: A Matplotlib-like interface for generating Tikz and Pgfplots figures
Keywords: tikz,plotting,matplotlib,pgfplots,latex
Author-email: Mathijs Schuurmans <mathijs.schuurmans@optia.be>
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2)
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Text Processing :: Markup :: LaTeX
Classifier: Topic :: Artistic Software
Classifier: Topic :: Software Development :: Code Generators
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Requires-Dist: numpy>=1.9
Requires-Dist: pytest ; extra == "dev"
Requires-Dist: sphinx ; extra == "dev"
Requires-Dist: pydata-sphinx-theme ; extra == "dev"
Requires-Dist: myst_parser ; extra == "dev"
Requires-Dist: sphinx-gallery ; extra == "dev"
Requires-Dist: sphinx-codeautolink ; extra == "dev"
Requires-Dist: matplotlib ; extra == "dev"
Requires-Dist: pdf2image ; extra == "dev"
Project-URL: Bug Tracker, https://github.com/Mathijssch/pykz/issues
Project-URL: Documentation, https://mathijssch.github.io/pykz
Project-URL: Source, https://github.com/Mathijssch/pykz
Provides-Extra: dev

<div align="center">
    <h1>Pykz</h1>
    <b>A Python library to generate tikz code</b><br><br>

[![Examples](https://img.shields.io/badge/docs-examples-green?style=flat-square)](https://mathijssch.github.io/pykz/gallery/index.html)
[![PyPI](https://img.shields.io/pypi/v/pykz?style=flat-square&logo=pypi&color=green)](https://pypi.org/project/pykz)
[![GitHub license](https://img.shields.io/github/license/mathijssch/pykz?style=flat-square&color=green)](https://github.com/Mathijssch/pykz/blob/main/LICENSE)<br><br>

</div>

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](https://github.com/nschloe/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.

```py
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()
```

<div align="center">
<img src="https://mathijssch.github.io/pykz/_images/sphx_glr_basic_inline_001.png" alt="Sample output" width="60%">
</div>

### 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.

```py
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:
```tex
\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}
```

<div align="center">
<img src="https://mathijssch.github.io/pykz/_images/sphx_glr_circles_and_squares_001.png" alt="Sample output" width="60%">
</div>

More examples can be found in the [online documentation](https://mathijssch.github.io/pykz).

