Skip to content

knightshock.figures

A module for creating useful figures using matplotlib.

Info

The functions and properties for the classes in this module are provided for convenience and are not required to utilize the functionality of the classes. The underlying Axes objects are exposed as object attributes to allow for standard use of the matplotlib interface.


IDTFigure(ax=None)

Class for creating ignition delay time figures with the standard layout:

  • Inverse temperature (1000/T) x-axis (bottom)
  • Log-scale IDT y-axis
  • Secondary temperature x-axis (top)

Functions are provided for plotting experimental data (add_exp) as scatter plots with or without error bars and for plotting model predictions from simulations (add_sim) as line plots, in addition to other functionality.

Important

Keyword arguments to functions are passed to the underlying matplotlib function calls and override the default property dicts set as class attributes.

Attributes:

  • ax

    Inverse temperature axis.

  • ax2

    Temperature axis.

Parameters:

  • ax (mpl.axes.Axes | None) –

    Existing matplotlib Axes object for plotting (optional).

exp_props = {'linestyle': 'None', 'marker': 'o'} class-attribute

Default properties for all experimental scatter (including errorbar) plots.

error_props = {'capsize': 5} class-attribute

Default properties for errorbar plots.

sim_props = {} class-attribute

Default properties for all simulation line plots.

units: str = 'μs' class-attribute

Default units for ignition delay time.

T_lim: tuple[float, float] property writable

Get/set the temperature [K] limits of the figure.

IDT_lim: tuple[float, float] property writable

Get/set the ignition delay time [units] limits of the figure.

add_exp(T, IDT, uncertainty=0, **kwargs)

Add experimental ignition delay data to the figure as scatter plots. If uncertainty is given, error bars are included.

Parameters:

  • T (int | float | npt.ArrayLike) –

    Temperatures [K].

  • IDT (int | float | npt.ArrayLike) –

    Ignition delay times [units].

  • uncertainty (float) –

    Experimental uncertainty as a fraction of IDT (optional).

add_sim(T, IDT, **kwargs)

Add ignition delay model predictions to the figure.

Parameters:

  • T (int | float | npt.ArrayLike) –

    Temperatures [K].

  • IDT (int | float | npt.ArrayLike) –

    Ignition delay times [units].

legend(**kwargs)

Create a legend for all data adding to the figure using add_exp or add_sim.