Skip to main content

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

Project description

License Python Version PyPI Version Codeberg Release Downloads Code Style: black Ruff ty
pre-commit PyTest Publish
Codeberg Issues Codeberg PRs Codeberg Stars Source Code

gypt_matplotlib

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


[!NOTE] To install gypt-matplotlib, simply use pip.

pip install gypt_matplotlib

GYPT?

GYPT stands for German Young Physicists’ Tournament.

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.

Where did you get the stylesheet?

It's available over here at the GYPT wiki.


How to use:

Applying GYPT-stylesheet

Just import the library. The stylesheet will be automatically applied.

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.

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

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
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
import gypt_matplotlib as gypt

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

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

gypt_matplotlib-0.7.0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

gypt_matplotlib-0.7.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file gypt_matplotlib-0.7.0.tar.gz.

File metadata

  • Download URL: gypt_matplotlib-0.7.0.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.12 Linux/6.12.57+deb13-amd64

File hashes

Hashes for gypt_matplotlib-0.7.0.tar.gz
Algorithm Hash digest
SHA256 1203cbf000fadf580267d6cbe21ab8fdff6fb3f2974beb017fe5d8324dcf6d36
MD5 0182fa8aec1a026dc5f6551f7b83d09a
BLAKE2b-256 9c8dc9a7efc8ffc3b556eb9948c7875bcceb5a0bb2330f8f70d6ed8fa49ae448

See more details on using hashes here.

File details

Details for the file gypt_matplotlib-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: gypt_matplotlib-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.12 Linux/6.12.57+deb13-amd64

File hashes

Hashes for gypt_matplotlib-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ddb8b960211c10d583da9ed3b9f68ef8a1606d7d814e53151f49c1da9df8907
MD5 78c101d37c7b29209e3ae2145a6ba8d6
BLAKE2b-256 18cc5333cfcae53e848bcb13996a1e17fda5c5c4e4b3a6e4e5d33647930b8070

See more details on using hashes here.

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