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 stands for German Young Physicists’ Tournament.
Further information can be found at gypt.org.
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.
It's available over here at the GYPT wiki.
Just import the library. The stylesheet will be automatically applied.
import gypt_matplotlib as gypt
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.")
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()``.
...
This library offers multiple utilities which can be used. The following utils are included:
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.}$
import gypt_matplotlib as gypt
print(gypt.tex(r"e^{i\pi}+1=0")) # $e^{i\pi}+1=0$