Convenient plot-configs with bundles

Convenient plot-configs with bundles#

[1]:
import matplotlib.pyplot as plt

from tueplots import axes, bundles

# Increase the resolution of all the plots below
plt.rcParams.update({"figure.dpi": 150})

tueplots provides a few prepackaged bundles that can be plugged right into matplotlib’s context manager.

[2]:
bundles.icml2022()
[2]:
{'text.usetex': True,
 'font.family': 'serif',
 'text.latex.preamble': '\\usepackage{times} ',
 'figure.figsize': (3.25, 2.0086104634371584),
 'figure.constrained_layout.use': True,
 'figure.autolayout': False,
 'savefig.bbox': 'tight',
 'savefig.pad_inches': 0.015,
 'font.size': 8,
 'axes.labelsize': 8,
 'legend.fontsize': 6,
 'xtick.labelsize': 6,
 'ytick.labelsize': 6,
 'axes.titlesize': 8}

Compare the default plots to the context plots below.

[3]:
fig, ax = plt.subplots()
ax.plot([1.0, 2.0], [3.0, 4.0])
ax.set_title("Title")
ax.set_xlabel("xlabel")
ax.set_ylabel("ylabel")
plt.show()
../_images/example_notebooks_bundles_5_0.png
[4]:
with plt.rc_context(bundles.neurips2021()):
    fig, ax = plt.subplots()
    ax.plot([1.0, 2.0], [3.0, 4.0])
    ax.set_title("Title")
    ax.set_xlabel("xlabel")
    ax.set_ylabel("ylabel")
    plt.show()
../_images/example_notebooks_bundles_6_0.png
[5]:
with plt.rc_context(bundles.jmlr2001(family="serif")):
    fig, ax = plt.subplots()
    ax.plot([1.0, 2.0], [3.0, 4.0])
    ax.set_title("Title")
    ax.set_xlabel("xlabel")
    ax.set_ylabel("ylabel")
    plt.show()
../_images/example_notebooks_bundles_7_0.png

To get some (subjective) default behaviour, combine the bundles with axes.lines() (which is highly customisable, but has some opinionated default arguments).

[6]:
with plt.rc_context({**bundles.neurips2021(), **axes.lines()}):
    fig, ax = plt.subplots()
    ax.plot([1.0, 2.0], [3.0, 4.0])
    ax.set_title("Title")
    ax.set_xlabel("xlabel")
    ax.set_ylabel("ylabel")
    plt.grid()
    plt.show()
../_images/example_notebooks_bundles_9_0.png
[7]:
with plt.rc_context(bundles.neurips2021(usetex=True, family="serif")):
    fig, ax = plt.subplots()
    ax.plot([1.0, 2.0], [3.0, 4.0])
    ax.set_title("Title")
    ax.set_xlabel("xlabel $\int f(x) dx$")
    ax.set_ylabel("ylabel $x \sim \mathcal{N}(x)$")
    plt.grid()
    plt.show()
../_images/example_notebooks_bundles_10_0.png
[8]:
with plt.rc_context({**bundles.icml2022(), **axes.lines()}):
    fig, ax = plt.subplots()
    ax.plot([1.0, 2.0], [3.0, 4.0], label="p(x)")
    ax.set_title("Title")
    ax.set_xlabel("xlabel $\int f(x) dx$")
    ax.set_ylabel("ylabel $x \sim \mathcal{N}(x)$")
    plt.grid()
    plt.legend()
    plt.show()
../_images/example_notebooks_bundles_11_0.png
[9]:
with plt.rc_context(bundles.aistats2022()):
    fig, ax = plt.subplots()
    ax.plot([1.0, 2.0], [3.0, 4.0], label="p(x)")
    ax.set_title("Title")
    ax.set_xlabel("xlabel $\int f(x) dx$")
    ax.set_ylabel("ylabel $x \sim \mathcal{N}(x)$")
    plt.grid()
    plt.legend()
    plt.show()
../_images/example_notebooks_bundles_12_0.png
[10]:
with plt.rc_context({**bundles.aistats2022(family="serif"), **axes.lines()}):
    fig, ax = plt.subplots()
    ax.plot([1.0, 2.0], [3.0, 4.0], label="p(x)")
    ax.set_title("Title")
    ax.set_xlabel("xlabel $\int f(x) dx$")
    ax.set_ylabel("ylabel $x \sim \mathcal{N}(x)$")
    plt.grid()
    plt.legend()
    plt.show()
../_images/example_notebooks_bundles_13_0.png
[11]:
with plt.rc_context(bundles.beamer_moml()):
    fig, ax = plt.subplots()
    ax.plot([1.0, 2.0], [3.0, 4.0], label="p(x)")
    ax.legend()
    ax.set_title("Title")
    ax.set_xlabel("xlabel")
    ax.set_ylabel("ylabel")
    ax.grid()
    plt.show()
../_images/example_notebooks_bundles_14_0.png
[12]:
with plt.rc_context(bundles.beamer_moml_dark_bg()):
    fig, ax = plt.subplots()
    ax.plot([1.0, 2.0], [3.0, 4.0])
    ax.set_title("Title")
    ax.set_xlabel("xlabel")
    ax.set_ylabel("ylabel")
    ax.grid()
    plt.show()
../_images/example_notebooks_bundles_15_0.png
[13]:
with plt.rc_context(bundles.iclr2023()):
    fig, ax = plt.subplots()
    ax.plot([1.0, 2.0], [3.0, 4.0])
    ax.set_title("Title")
    ax.set_xlabel("xlabel")
    ax.set_ylabel("ylabel")
    ax.grid()
    plt.show()
../_images/example_notebooks_bundles_16_0.png
[14]:
with plt.rc_context(
    bundles.iclr2023(usetex=True, nrows=1, ncols=3, family="smallcaps")
):
    fig, ax = plt.subplots()
    ax.plot([1.0, 2.0], [3.0, 4.0])
    ax.set_title("Title")
    ax.set_xlabel("xlabel")
    ax.set_ylabel("ylabel")
    ax.grid()
    plt.show()
../_images/example_notebooks_bundles_17_0.png