PlotDefinition#

Module: exa.core.analyze_result.plot_definition

class PlotDefinition(function, default_kwargs)#

Bases: object

Defines a way to generate a Figure from an Xarray dataset.

Attributes

function

A callable that generates the figure.

default_kwargs

Default keyword arguments that will be passed to function, if not overridden.

Methods

embed_base64

Generate a figure and encode it in base64, so that it can be embedded to an img HTML attribute.

generate_from_dataset

Generate a figure from xarray.Dataset by calling function.

generate_from_run_result

Generate a figure from RunResult by calling function.

Parameters:
function: Callable[[...], Figure]#

A callable that generates the figure. The first and only positional argument of function must be the run result where the data is read from. function can accept keyword arguments and must return a single Figure.

default_kwargs: dict[str, Any]#

Default keyword arguments that will be passed to function, if not overridden.

generate_from_run_result(run_result, /, **kwargs)#

Generate a figure from RunResult by calling function.

Parameters:
  • run_result (RunResult) – The run result containing the full dataset and run data.

  • kwargs – Keyword arguments passed to function. These override default_kwargs.

Returns:

A new Figure.

Return type:

Figure

generate_from_dataset(dataset, /, **kwargs)#

Generate a figure from xarray.Dataset by calling function.

Parameters:
Returns:

A new Figure.

Return type:

Figure

embed_base64(data)#

Generate a figure and encode it in base64, so that it can be embedded to an img HTML attribute.

Parameters:

data (RunResult | Dataset) – The run result containing the full dataset and run data, or the full dataset.

Returns:

A base64 representation of the figure. If rendering the figure fails for any reason, the error message

will be returned as an alt text instead.

Return type:

str

Inheritance

Inheritance diagram of exa.core.analyze_result.plot_definition.PlotDefinition