ccu.fancyplots.data

Classes for the storage of FancyPlots relevant data.

The class ccu.fancyplots.data.FancyCache describes how data is imported to and exported from FancyPlots.

The class ccu.fancyplots.data.FEDData defines how free energy diagram is stored.

The class ccu.fancyplots.data.FormattingParameters defines how plot formatting parameters are stored.

The class ccu.fancyplots.data.Annotation defines how plot annotations are stored.

Examples

The internal data from FancyPlots can be accessed via the attribute ccu.fancyplots._gui.root.FancyPlotsGUI.cache and dumped into a human-readable form via the following idiom:

>>> import json
>>> from pathlib import Path
>>> from ccu.fancyplots.data import DEFAULT_PARAMETERS
>>> from ccu.fancyplots.data import FancyCache
>>> data = {
...     "energy_data": [
...         [0, 0.2, 0.33, -0.5],
...         [0, -0.1, 0.25, 0],
...     "mechanism": ["*", "*CHOO", "*CO", "CO"],
...     "legend_labels: ["Cu(111)", "Cu-NP"],
>>> annotations = []
>>> formatting_parameters = DEFAULT_PARAMETERS
>>> cache = FancyCache(
...     formatting_parameters,
...     diagram_data=data,
...     annotations=annotations,
...)
>>> with Path("fancy.cache").open(
...     mode="w", encoding="utf-8"
... ) as file:  
...     _ = json.dump(cache, file, indent=2)

The same file (fancy.cache) can be loaded into a convenient format for FancyPlots via the following idiom:

>>> import json
>>> from pathlib import Path
>>> from ccu.fancyplots.data import FancyCache
>>> with Path("fancy.cache").open(  
...     mode="r", encoding="utf-8"
... ) as file:
...     cache = FancyCache(**json.load(file))
class ccu.fancyplots.data.Annotation(color: str = 'k', fontsize: float = 11.2, text: str = '', x: float = 0.0, y: float = 0.0)[source]

Bases: NamedTuple

A free energy diagram annotation.

Variables:
  • color (str) – The color to use for the annotation.

  • fontsize (float) – The fontsize to use for the annotation.

  • text (str) – The annotation text.

  • x (float) – The x-coordinate of the annotation.

  • y (float) – The y-coordinate of the annotation.

Create new instance of Annotation(color, fontsize, text, x, y)

_asdict()

Return a new dict which maps field names to their values.

_field_defaults = {'color': 'k', 'fontsize': 11.2, 'text': '', 'x': 0.0, 'y': 0.0}
_fields = ('color', 'fontsize', 'text', 'x', 'y')
classmethod _make(iterable)

Make a new Annotation object from a sequence or iterable

_replace(**kwds)

Return a new Annotation object replacing specified fields with new values

color: str

Alias for field number 0

fontsize: float

Alias for field number 1

text: str

Alias for field number 2

x: float

Alias for field number 3

y: float

Alias for field number 4

ccu.fancyplots.data.DEFAULT_PARAMETERS = {'boxsize': (6, 4.5), 'colors': ('black', 'blue', 'red', 'lime', 'fuchsia'), 'dpi': 1200, 'font': 'Sans Serif', 'fontsize': 14, 'legend_loc': 'best', 'linewidth': 2.25, 'markeredgewidth': 0.3, 'markersize': 7, 'savename': 'fed.svg', 'tick_dec': 2, 'tick_double': False, 'tick_loc': 'out', 'tick_min': 0, 'title': '', 'xlabel': 'Reaction Coordinate', 'xlim': None, 'xscale': None, 'ylabel': '$\\Delta$G / eV', 'ylim': None, 'yscale': 'linear'}

The default formatting parameters for FancyPlots

class ccu.fancyplots.data.FEDData[source]

Bases: TypedDict

Energies and metadata for a free energy diagram.

Variables:
  • energy_data (list[list[float | None]]) – A list of lists. Each list defines energies for each step in the mechanism.

  • mechanism (list[str]) – The labels for each mechanism step.

  • legend_labels (list[str | None]) – The legend labels for each pathway.

Valid ccu.fancyplots.data.FEDData instances should satisfy the following condition for seamless use with FancyPlots:

energy_data: list[list[float | None]]
legend_labels: list[str | None]
mechanism: list[str]
class ccu.fancyplots.data.FancyCache(style_parameters: FormattingParameters, diagram_data: FEDData, annotations: list[Annotation])[source]

Bases: object

The data model for caching/loading data into FancyPlots.

Variables:
annotations: list[Annotation]
diagram_data: FEDData
save(savename: str | Path = 'cache..fancy') None[source]

Save the FancyCache.

Parameters:
  • savename – The filename in which to save the cache. Defaults to

  • f”cache.{FANCY_EXTENSION}”.

style_parameters: FormattingParameters
class ccu.fancyplots.data.FormattingParameters[source]

Bases: TypedDict

The formatting parameters to use to plot free energy diagrams.

Keys:

boxsize: tuple[float, float]
colors: tuple[str, ...]
dpi: int
font: str
fontsize: float
legend_loc: str
linewidth: float
markeredgewidth: float
markersize: int
savename: str
tick_dec: float
tick_double: bool
tick_loc: str
tick_min: float
title: str
visual: bool
xlabel: str
xlim: None | tuple[float, float]
xscale: str
ylabel: str
ylim: None | tuple[float, float]
yscale: str