gypt_matplotlib 0.4.5
A small addon for matplotlib that can be used for the GYPT.
Requires Python: >=3.12
Keywords: Albert Unruh, GYPT, German Young Physicists' Tournament, matplotlib, addon

[![License](https://img.shields.io/pypi/l/gypt_matplotlib?style=flat&label=License&logo=data:image/svg%2bxml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIGZpbGw9IiMwMDAwMDAiIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0yMS45LDExLjU1M2wtMy02YS44NDYuODQ2LDAsMCwwLS4xNjQtLjIyNUEuOTg3Ljk4NywwLDAsMCwxOCw1SDEzVjNhMSwxLDAsMCwwLTIsMFY1SDZhLjk4Ny45ODcsMCwwLDAtLjczMS4zMjguODQ2Ljg0NiwwLDAsMC0uMTY0LjIyNWwtMyw2YS45ODIuOTgyLDAsMCwwLS4xLjQ0N0gyYTQsNCwwLDAsMCw4LDBIOS45OWEuOTgyLjk4MiwwLDAsMC0uMS0uNDQ3TDcuNjE4LDdIMTFWMjBINmExLDEsMCwwLDAsMCwySDE4YTEsMSwwLDAsMCwwLTJIMTNWN2gzLjM4MmwtMi4yNzcsNC41NTNhLjk4Mi45ODIsMCwwLDAtLjEuNDQ3SDE0YTQsNCwwLDAsMCw4LDBoLS4wMUEuOTgyLjk4MiwwLDAsMCwyMS45LDExLjU1M1pNNy44ODIsMTJINC4xMThMNiw4LjIzNlptOC4yMzYsMEwxOCw4LjIzNiwxOS44ODIsMTJaIi8+PC9zdmc+)](https://codeberg.org/AlbertUnruh/gypt-matplotlib/src/branch/develop/LICENSE)
[![Python Version](https://img.shields.io/pypi/pyversions/gypt_matplotlib.svg?style=flat&label=Python&logo=Python)](https://python.org)
[![PyPI Version](https://img.shields.io/pypi/v/gypt_matplotlib?logo=pypi&label=PyPi)](https://pypi.org/project/gypt_matplotlib/)
[![Codeberg Release](https://codeberg.org/AlbertUnruh/gypt-matplotlib/badges/release.svg)](https://codeberg.org/AlbertUnruh/gypt-matplotlib/releases)
[![Downloads](https://img.shields.io/pepy/dt/gypt_matplotlib?logo=data:image/svg%2bxml%3Bbase64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMTcgMTdIMTcuMDFNMTcuNCAxNEgxOEMxOC45MzE5IDE0IDE5LjM5NzggMTQgMTkuNzY1NCAxNC4xNTIyQzIwLjI1NTQgMTQuMzU1MiAyMC42NDQ4IDE0Ljc0NDYgMjAuODQ3OCAxNS4yMzQ2QzIxIDE1LjYwMjIgMjEgMTYuMDY4MSAyMSAxN0MyMSAxNy45MzE5IDIxIDE4LjM5NzggMjAuODQ3OCAxOC43NjU0QzIwLjY0NDggMTkuMjU1NCAyMC4yNTU0IDE5LjY0NDggMTkuNzY1NCAxOS44NDc4QzE5LjM5NzggMjAgMTguOTMxOSAyMCAxOCAyMEg2QzUuMDY4MTIgMjAgNC42MDIxOCAyMCA0LjIzNDYzIDE5Ljg0NzhDMy43NDQ1OCAxOS42NDQ4IDMuMzU1MjMgMTkuMjU1NCAzLjE1MjI0IDE4Ljc2NTRDMyAxOC4zOTc4IDMgMTcuOTMxOSAzIDE3QzMgMTYuMDY4MSAzIDE1LjYwMjIgMy4xNTIyNCAxNS4yMzQ2QzMuMzU1MjMgMTQuNzQ0NiAzLjc0NDU4IDE0LjM1NTIgNC4yMzQ2MyAxNC4xNTIyQzQuNjAyMTggMTQgNS4wNjgxMiAxNCA2IDE0SDYuNk0xMiAxNVY0TTEyIDE1TDkgMTJNMTIgMTVMMTUgMTIiIHN0cm9rZT0iIzAwMDAwMCIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+&label=Downloads)](https://pepy.tech/project/gypt_matplotlib)
[![Code Style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
</br>
[![pre-commit](https://codeberg.org/AlbertUnruh/gypt-matplotlib/badges/workflows/pre-commit.yaml/badge.svg)](https://codeberg.org/AlbertUnruh/gypt-matplotlib/actions?workflow=pre-commit.yaml)
[![PyTest](https://codeberg.org/AlbertUnruh/gypt-matplotlib/badges/workflows/pytest.yaml/badge.svg)](https://codeberg.org/AlbertUnruh/gypt-matplotlib/actions?workflow=pytest.yaml)
[![Publish](https://codeberg.org/AlbertUnruh/gypt-matplotlib/badges/workflows/publish.yaml/badge.svg)](https://codeberg.org/AlbertUnruh/gypt-matplotlib/actions?workflow=publish.yaml)
</br>
[![Codeberg Issues](https://codeberg.org/AlbertUnruh/gypt-matplotlib/badges/issues/open.svg)](https://codeberg.org/AlbertUnruh/gypt-matplotlib/issues)
[![Codeberg PRs](https://codeberg.org/AlbertUnruh/gypt-matplotlib/badges/pulls/open.svg)](https://codeberg.org/AlbertUnruh/gypt-matplotlib/pulls)
[![Codeberg Stars](https://codeberg.org/AlbertUnruh/gypt-matplotlib/badges/stars.svg?color=gold)](https://codeberg.org/AlbertUnruh/gypt-matplotlib/stars)
[![Source Code](https://img.shields.io/badge/Source%20Code-grey?logo=codeberg&style=flat)](https://codeberg.org/AlbertUnruh/gypt-matplotlib)


# gypt_matplotlib
A small addon for matplotlib that can be used for the GYPT.

---

> [!NOTE]
> To install `gypt-matplotlib`, simply use `pip`.
> ```cmd
> pip install gypt_matplotlib
> ```

---

### GYPT?
GYPT stands for **G**erman **Y**oung **P**hysicists’ **T**ournament.

Further information can be found at [gypt.org][].


### I'm a participant of the GYPT. Can I contribute?
Of course, you can.
Even if you are just a former participant, you are welcome.
In fact, everyone is welcome to contribute or ask for features!

Simply open an [issue][] and say what you would like to do so that details can be clarified directly.


[issue]: https://codeberg.org/AlbertUnruh/gypt-matplotlib/issues


### Where did you get the stylesheet?
It's available over [here][stylesheet] at the [GYPT wiki][wiki].


[gypt.org]: https://gypt.org
[wiki]: https://wiki.gypt.org
[stylesheet]: https://wiki.gypt.org/index.php/Python/stylesheet


---

### How to use:

#### Applying GYPT-stylesheet
Just import the library. The stylesheet will be automatically applied.
```python
import gypt_matplotlib as gypt
```

#### Creating plots with ``a.u.`` (arbitrary units)
You can use the context manager ``gypt.au_plot()``
to create plots where the concept and not the actual numbers are important.
```python
import matplotlib.pyplot as plt
import gypt_matplotlib as gypt

with gypt.au_plot():
    plt.title("Demo of plot without numbers on X-/Y-Axis.")
    plt.show()

# or even more advanced:
with gypt.au_plot(), gypt.auto_save_and_show("path/to/file.png"):
    plt.title("Demo of plot without numbers on X-/Y-Axis.")
```

#### Using other diverse context managers
```python
import matplotlib.pyplot as plt
import gypt_matplotlib as gypt

with gypt.auto_close():
    # This context manager automatically calls ``plt.close()``.
    # Saving and displaying have to be done manually!
    ...

with gypt.auto_show():
    # This context manager automatically calls ``plt.show()`` and ``plt.close()``.
    # It's incompatible with ``gypt.auto_save()``! Use ``gypt.auto_save_and_show()`` instead!
    ...

with gypt.auto_save("path/to/file.png"):
    # This context manager automatically calls ``plt.savefig()`` and ``plt.close()``.
    # It's incompatible with ``gypt.auto_show()``! Use ``gypt.auto_save_and_show()`` instead!
    ...

with gypt.auto_save_and_show("path/to/file.png"):
    # This context manager automatically calls ``plt.savefig()``, ``plt.show()`` and ``plt.close()``.
    ...
```

#### Using ``utils``
This library offers multiple utilities which can be used.
The following utils are included:
- [``axes_label``](#axes_label)
- [``tex``](#tex)

##### ``axes_label``
```python
import gypt_matplotlib as gypt

# with a unit
print(gypt.axes_label("v", unit=r"\frac{m}{s}"))  # $v$ in $\frac{m}{s}$

# with arbitrary unit
print(gypt.axes_label("I", is_au=True))  # $I$ in $\text{a.u.}$
```

##### ``tex``
```python
import gypt_matplotlib as gypt

print(gypt.tex(r"e^{i\pi}+1=0"))  # $e^{i\pi}+1=0$
```