Skip to content

plot

thmd.post.plot ¤

This module provides functions and class to produce publication-quality figures. The main idea is to create a handy class which setup all necessary parameters for plotting, and then just call its methods to produce the publication-quality figures.

The core class is the Plotter, which is built on top of matplotlib.pyplot. The Plotter, therefore, has all useful functions from matplotlib.pyplot.

Assume we have a data frame df:

import numpy as np
import polars as pl

x = np.arange(0, 1000)
df = pl.DataFrame({"x": x, "y": x**2})

Then, use the Plotter().plt to plot the data as a normal matplotlib.pyplot object. Adapt all functions from matplotlib.pyplot.

from thmd.plot import Plotter

plt = Plotter(style="thang").plt
plt.plot(df["x"], df["y"])
plt.show()

Refs
  1. Customizing Matplotlib with style sheets and rcParams
  2. Figure size Elsevier
    • Single column: W = 90 mm (~3.5 in). H = W*⅘ = 2.8
    • Double column: W = 190 mm (~7.5 in). H = 6

Classes:

  • Plotter

    Class to produce publication-quality figures with matplotlib.

Functions:

Plotter() ¤

Class to produce publication-quality figures with matplotlib.

Examples:

from thmd.post.plot import Plotter

plt = Plotter().get_plt(style="thang")  # shortcut to matplotlib.pyplot
plt.plot(df["x"], df["y"])

Methods:

Attributes:

COLOR = _COLOR instance-attribute ¤

MARKER = _MARKER instance-attribute ¤

LINE = _LINE instance-attribute ¤

info property ¤

get_plt(style: str = 'thang') ¤

Shortcut to the matplotlib.pyplot object.

set_minor_locator(ax: object, xminor=1, yminor=1) ¤

Set minor locator for axes.

get_PdfPages() ¤

Shortcut to matplotlib.backends.backend_pdf.PdfPages.

avail_styles() ¤

List all available styles.

custom_styles() ¤

Style for matplotlib.