Plotting Module

class mmpp.plotting.PlotConfig(figsize=(12, 8), dpi=100, style='paper', colormap='viridis', line_alpha=0.7, line_width=1.5, grid=True, legend=True, title_fontsize=14, label_fontsize=12, tick_fontsize=10, use_custom_fonts=True, font_family='Arial', colors=None, max_legend_params=4, sort_results=True)[source]

Bases: object

Configuration for plotting operations.

Parameters:
figsize: tuple = (12, 8)
dpi: int = 100
style: str = 'paper'
colormap: str = 'viridis'
line_alpha: float = 0.7
line_width: float = 1.5
grid: bool = True
legend: bool = True
title_fontsize: int = 14
label_fontsize: int = 12
tick_fontsize: int = 10
use_custom_fonts: bool = True
font_family: str = 'Arial'
colors: Optional[dict[str, str]] = None
max_legend_params: int = 4
sort_results: bool = True
__post_init__()[source]

Initialize default colors.

Return type:

None

__init__(figsize=(12, 8), dpi=100, style='paper', colormap='viridis', line_alpha=0.7, line_width=1.5, grid=True, legend=True, title_fontsize=14, label_fontsize=12, tick_fontsize=10, use_custom_fonts=True, font_family='Arial', colors=None, max_legend_params=4, sort_results=True)
Parameters:
class mmpp.plotting.FontManager[source]

Bases: object

Font management utilities for plotting.

static get_available_fonts()[source]

Get list of available fonts on the system.

Return type:

list[str]

class mmpp.plotting.PlotterProxy(results, mmpp_instance=None)[source]

Bases: object

Proxy class to provide plotting functionality to search results.

Parameters:
__init__(results, mmpp_instance=None)[source]

Initialize the plotter proxy.

Parameters:

resultsList[Any]

List of results to plot

mmpp_instanceOptional[Any]

Reference to MMPP instance

param results:

type results:

list[Any]

param mmpp_instance:

type mmpp_instance:

Optional[Any]

__getattr__(name)[source]

Delegate attribute access to MMPPlotter.

Parameters:

name (str)

Return type:

Any

__repr__()[source]

String representation of the proxy.

Return type:

str

mmpp.plotting.setup_custom_fonts(verbose=False)[source]

Setup custom fonts including Arial.

Parameters:

verbose (bool)

Return type:

bool

mmpp.plotting.load_paper_style(verbose=False)[source]

Load custom paper style.

Parameters:

verbose (bool)

Return type:

bool

mmpp.plotting.apply_custom_colors(colors)[source]

Apply custom colors to matplotlib rcParams.

Parameters:

colors (dict[str, str])

Return type:

None

class mmpp.plotting.MMPPlotter(results, mmpp_instance=None)[source]

Bases: object

Advanced plotting functionality for MMPP results.

This class provides comprehensive plotting capabilities including: - Time series plotting with averaging - Multiple datasets comparison - Component selection (x, y, z) - Professional styling and customization - Custom fonts and paper-ready styling

Parameters:
__init__(results, mmpp_instance=None)[source]

Initialize the plotter.

Parameters:

resultsList or single result

ZarrJobResult objects to plot

mmpp_instanceMMPP, optional

Reference to the parent MMPP instance

param results:

type results:

Union[list[Any], Any]

param mmpp_instance:

type mmpp_instance:

Optional[Any]

__repr__()[source]

Rich representation of the plotter.

Return type:

str

configure(**kwargs)[source]

Configure plot settings.

Return type:

MMPPlotter

Parameters:

**kwargsAny

Configuration options: - figsize : tuple - Figure size (width, height), default (12, 8) - dpi : int - Figure DPI, default 100 - style : str - Matplotlib style, default “paper” - colormap : str - Colormap name, default “viridis” - line_alpha : float - Line transparency, default 0.7 - line_width : float - Line width, default 1.5 - grid : bool - Show grid, default True - legend : bool - Show legend, default True - title_fontsize : int - Title font size, default 14 - label_fontsize : int - Label font size, default 12 - tick_fontsize : int - Tick font size, default 10 - use_custom_fonts : bool - Use custom fonts, default True - font_family : str - Font family, default “Arial” - colors : dict - Custom colors for text/axes/grid - max_legend_params : int - Max parameters in legend, default 4 - sort_results : bool - Sort results by parameters, default True

Returns:

: MMPPlotter

Self for method chaining

Examples:

>>> plotter.configure(sort_results=False, max_legend_params=6)
>>> plotter.configure(style='dark_background', grid=False)
reset_style()[source]

Reset to paper style with Arial font.

Return type:

MMPPlotter

Returns:

: MMPPlotter

Self for method chaining

set_style(style_name)[source]

Set matplotlib style.

Return type:

MMPPlotter

Parameters:

style_namestr

Name of the matplotlib style

Returns:

: MMPPlotter

Self for method chaining

param style_name:

type style_name:

str

get_available_styles()[source]

Get list of available matplotlib styles.

Return type:

list[str]

Returns:

: List[str]

List of available style names

plot(x_series, y_series, comp=None, average=None, figsize=None, title=None, xlabel=None, ylabel=None, legend_labels=None, legend_variables=None, colors=None, save_path=None, paper_ready=False, **kwargs)[source]

Create a plot for the specified data series.

Return type:

tuple

Parameters:

x_seriesstr

Name of x-axis data (e.g., ‘t’ for time)

y_seriesstr

Name of y-axis dataset (e.g., ‘m_z11’)

compUnion[str, int], optional

Component to plot (‘x’/’y’/’z’ or 0/1/2)

averagetuple, optional

Axes to average over (e.g., (1,2,3) for spatial averaging)

figsizetuple, optional

Figure size (width, height)

titleUnion[str, List[str]], optional

Plot title. Can be: - str: Custom title text - List[str]: Parameter names to show in title (e.g., [‘amp’, ‘f0’] -> “Amp = 0.1, F0 = 1e9”)

xlabelstr, optional

X-axis label

ylabelstr, optional

Y-axis label

legend_labelsList[str], optional

Custom legend labels

legend_variablesList[str], optional

Specific variables to show in legend (e.g., [‘maxerr’, ‘f0’]). If provided, overrides automatic varying parameter detection.

colorsList[str], optional

Custom colors for each line

save_pathstr, optional

Path to save the figure

paper_readybool, optional

If True, apply paper-ready styling (default: False)

**kwargsAny

Additional matplotlib plot arguments

Returns:

: tuple

(figure, axes) matplotlib objects

param x_series:

type x_series:

str

param y_series:

type y_series:

str

param comp:

type comp:

Union[str, int, None]

param average:

type average:

Optional[tuple[Any, ...]]

param figsize:

type figsize:

Optional[tuple[Any, ...]]

param title:

type title:

Union[str, list[str], None]

param xlabel:

type xlabel:

Optional[str]

param ylabel:

type ylabel:

Optional[str]

param legend_labels:

type legend_labels:

Optional[list[str]]

param legend_variables:

type legend_variables:

Optional[list[str]]

param colors:

type colors:

Optional[list[str]]

param save_path:

type save_path:

Optional[str]

param paper_ready:

type paper_ready:

bool

param kwargs:

type kwargs:

Any

plot_time_series(dataset, comp='z', average=(1, 2, 3), **kwargs)[source]

Convenience method for time series plotting.

Return type:

tuple

Parameters:

datasetstr

Dataset name (e.g., ‘m_z11’)

compUnion[str, int], optional

Component (‘x’/’y’/’z’ or 0/1/2, default: ‘z’)

averagetuple, optional

Spatial axes to average over (default: (1,2,3))

**kwargsAny

Additional arguments passed to plot()

Returns:

: tuple

(figure, axes) matplotlib objects

param dataset:

type dataset:

str

param comp:

type comp:

Union[str, int]

param average:

type average:

tuple

param kwargs:

type kwargs:

Any

plot_components(dataset, time_slice=-1, average=(1, 2, 3), **kwargs)[source]

Plot all three components of a dataset.

Return type:

tuple

Parameters:

datasetstr

Dataset name

time_sliceint, optional

Time slice to plot (default: -1 for last)

averagetuple, optional

Axes to average over

**kwargsAny

Additional plot arguments

Returns:

: tuple

(figure, axes) matplotlib objects

param dataset:

type dataset:

str

param time_slice:

type time_slice:

int

param average:

type average:

tuple

param kwargs:

type kwargs:

Any

get_plot_data()[source]

Get data from the last plot for further analysis.

Return type:

list[dict]

Returns:

: List[Dict]

List of dictionaries containing plot data and metadata

save_all_data(filename, format='npz')[source]

Save all plotted data to file.

Return type:

None

Parameters:

filenamestr

Output filename

formatstr, optional

Format (‘npz’, ‘csv’, ‘json’)

param filename:

type filename:

str

param format:

type format:

str

snapshot(dset=None, z=0, t=-1, ax=None, repeat=1, zero=None)[source]

Create a snapshot visualization of magnetization data.

Return type:

Any

Parameters:

dsetstr, optional

Dataset name. If None, automatically selects the largest m dataset. Dataset name to visualize

zint, default 0

Z-slice to display

tint, default -1

Time step to display (-1 for last)

axOptional[Axes], default None

Matplotlib axes to plot on (creates new if None)

repeatint, default 1

Number of times to tile the image

zeroOptional[bool], default None

Reference time step to subtract (for difference plots)

Returns:

: Axes

Matplotlib axes object with the plot

param dset:

type dset:

Optional[str]

param z:

type z:

int

param t:

type t:

int

param ax:

type ax:

Optional[Any]

param repeat:

type repeat:

int

param zero:

type zero:

Optional[bool]

mmpp.plotting.hsl2rgb(hsl)[source]

Convert HSL color space to RGB.

Return type:

ndarray

Parameters:

hslnp.ndarray

HSL color array with shape (…, 3)

Returns:

: np.ndarray

RGB color array with same shape

param hsl:

type hsl:

ndarray

mmpp.plotting.rgb2hsl(rgb)[source]

Convert RGB color space to HSL.

Return type:

ndarray

Parameters:

rgbnp.ndarray

RGB color array with shape (…, 3)

Returns:

: np.ndarray

HSL color array with same shape

param rgb:

type rgb:

ndarray

class mmpp.plotting.FontUtils[source]

Bases: object

Utility object for font management.

static get_available()[source]

Get available fonts.

Return type:

list[str]

static setup_custom(verbose=True)[source]

Setup custom fonts.

Parameters:

verbose (bool)

Return type:

bool

Plotting Classes

MMPPlotter

class mmpp.plotting.MMPPlotter(results, mmpp_instance=None)[source]

Bases: object

Advanced plotting functionality for MMPP results.

This class provides comprehensive plotting capabilities including: - Time series plotting with averaging - Multiple datasets comparison - Component selection (x, y, z) - Professional styling and customization - Custom fonts and paper-ready styling

Parameters:
__init__(results, mmpp_instance=None)[source]

Initialize the plotter.

Parameters:

resultsList or single result

ZarrJobResult objects to plot

mmpp_instanceMMPP, optional

Reference to the parent MMPP instance

param results:

type results:

Union[list[Any], Any]

param mmpp_instance:

type mmpp_instance:

Optional[Any]

__repr__()[source]

Rich representation of the plotter.

Return type:

str

configure(**kwargs)[source]

Configure plot settings.

Return type:

MMPPlotter

Parameters:

**kwargsAny

Configuration options: - figsize : tuple - Figure size (width, height), default (12, 8) - dpi : int - Figure DPI, default 100 - style : str - Matplotlib style, default “paper” - colormap : str - Colormap name, default “viridis” - line_alpha : float - Line transparency, default 0.7 - line_width : float - Line width, default 1.5 - grid : bool - Show grid, default True - legend : bool - Show legend, default True - title_fontsize : int - Title font size, default 14 - label_fontsize : int - Label font size, default 12 - tick_fontsize : int - Tick font size, default 10 - use_custom_fonts : bool - Use custom fonts, default True - font_family : str - Font family, default “Arial” - colors : dict - Custom colors for text/axes/grid - max_legend_params : int - Max parameters in legend, default 4 - sort_results : bool - Sort results by parameters, default True

Returns:

: MMPPlotter

Self for method chaining

Examples:

>>> plotter.configure(sort_results=False, max_legend_params=6)
>>> plotter.configure(style='dark_background', grid=False)
reset_style()[source]

Reset to paper style with Arial font.

Return type:

MMPPlotter

Returns:

: MMPPlotter

Self for method chaining

set_style(style_name)[source]

Set matplotlib style.

Return type:

MMPPlotter

Parameters:

style_namestr

Name of the matplotlib style

Returns:

: MMPPlotter

Self for method chaining

param style_name:

type style_name:

str

get_available_styles()[source]

Get list of available matplotlib styles.

Return type:

list[str]

Returns:

: List[str]

List of available style names

plot(x_series, y_series, comp=None, average=None, figsize=None, title=None, xlabel=None, ylabel=None, legend_labels=None, legend_variables=None, colors=None, save_path=None, paper_ready=False, **kwargs)[source]

Create a plot for the specified data series.

Return type:

tuple

Parameters:

x_seriesstr

Name of x-axis data (e.g., ‘t’ for time)

y_seriesstr

Name of y-axis dataset (e.g., ‘m_z11’)

compUnion[str, int], optional

Component to plot (‘x’/’y’/’z’ or 0/1/2)

averagetuple, optional

Axes to average over (e.g., (1,2,3) for spatial averaging)

figsizetuple, optional

Figure size (width, height)

titleUnion[str, List[str]], optional

Plot title. Can be: - str: Custom title text - List[str]: Parameter names to show in title (e.g., [‘amp’, ‘f0’] -> “Amp = 0.1, F0 = 1e9”)

xlabelstr, optional

X-axis label

ylabelstr, optional

Y-axis label

legend_labelsList[str], optional

Custom legend labels

legend_variablesList[str], optional

Specific variables to show in legend (e.g., [‘maxerr’, ‘f0’]). If provided, overrides automatic varying parameter detection.

colorsList[str], optional

Custom colors for each line

save_pathstr, optional

Path to save the figure

paper_readybool, optional

If True, apply paper-ready styling (default: False)

**kwargsAny

Additional matplotlib plot arguments

Returns:

: tuple

(figure, axes) matplotlib objects

param x_series:

type x_series:

str

param y_series:

type y_series:

str

param comp:

type comp:

Union[str, int, None]

param average:

type average:

Optional[tuple[Any, ...]]

param figsize:

type figsize:

Optional[tuple[Any, ...]]

param title:

type title:

Union[str, list[str], None]

param xlabel:

type xlabel:

Optional[str]

param ylabel:

type ylabel:

Optional[str]

param legend_labels:

type legend_labels:

Optional[list[str]]

param legend_variables:

type legend_variables:

Optional[list[str]]

param colors:

type colors:

Optional[list[str]]

param save_path:

type save_path:

Optional[str]

param paper_ready:

type paper_ready:

bool

param kwargs:

type kwargs:

Any

plot_time_series(dataset, comp='z', average=(1, 2, 3), **kwargs)[source]

Convenience method for time series plotting.

Return type:

tuple

Parameters:

datasetstr

Dataset name (e.g., ‘m_z11’)

compUnion[str, int], optional

Component (‘x’/’y’/’z’ or 0/1/2, default: ‘z’)

averagetuple, optional

Spatial axes to average over (default: (1,2,3))

**kwargsAny

Additional arguments passed to plot()

Returns:

: tuple

(figure, axes) matplotlib objects

param dataset:

type dataset:

str

param comp:

type comp:

Union[str, int]

param average:

type average:

tuple

param kwargs:

type kwargs:

Any

plot_components(dataset, time_slice=-1, average=(1, 2, 3), **kwargs)[source]

Plot all three components of a dataset.

Return type:

tuple

Parameters:

datasetstr

Dataset name

time_sliceint, optional

Time slice to plot (default: -1 for last)

averagetuple, optional

Axes to average over

**kwargsAny

Additional plot arguments

Returns:

: tuple

(figure, axes) matplotlib objects

param dataset:

type dataset:

str

param time_slice:

type time_slice:

int

param average:

type average:

tuple

param kwargs:

type kwargs:

Any

get_plot_data()[source]

Get data from the last plot for further analysis.

Return type:

list[dict]

Returns:

: List[Dict]

List of dictionaries containing plot data and metadata

save_all_data(filename, format='npz')[source]

Save all plotted data to file.

Return type:

None

Parameters:

filenamestr

Output filename

formatstr, optional

Format (‘npz’, ‘csv’, ‘json’)

param filename:

type filename:

str

param format:

type format:

str

snapshot(dset=None, z=0, t=-1, ax=None, repeat=1, zero=None)[source]

Create a snapshot visualization of magnetization data.

Return type:

Any

Parameters:

dsetstr, optional

Dataset name. If None, automatically selects the largest m dataset. Dataset name to visualize

zint, default 0

Z-slice to display

tint, default -1

Time step to display (-1 for last)

axOptional[Axes], default None

Matplotlib axes to plot on (creates new if None)

repeatint, default 1

Number of times to tile the image

zeroOptional[bool], default None

Reference time step to subtract (for difference plots)

Returns:

: Axes

Matplotlib axes object with the plot

param dset:

type dset:

Optional[str]

param z:

type z:

int

param t:

type t:

int

param ax:

type ax:

Optional[Any]

param repeat:

type repeat:

int

param zero:

type zero:

Optional[bool]

PlotterProxy

class mmpp.plotting.PlotterProxy(results, mmpp_instance=None)[source]

Bases: object

Proxy class to provide plotting functionality to search results.

Parameters:
__init__(results, mmpp_instance=None)[source]

Initialize the plotter proxy.

Parameters:

resultsList[Any]

List of results to plot

mmpp_instanceOptional[Any]

Reference to MMPP instance

param results:

type results:

list[Any]

param mmpp_instance:

type mmpp_instance:

Optional[Any]

__getattr__(name)[source]

Delegate attribute access to MMPPlotter.

Parameters:

name (str)

Return type:

Any

__repr__()[source]

String representation of the proxy.

Return type:

str

Configuration Classes

class mmpp.plotting.PlotConfig(figsize=(12, 8), dpi=100, style='paper', colormap='viridis', line_alpha=0.7, line_width=1.5, grid=True, legend=True, title_fontsize=14, label_fontsize=12, tick_fontsize=10, use_custom_fonts=True, font_family='Arial', colors=None, max_legend_params=4, sort_results=True)[source]

Bases: object

Configuration for plotting operations.

Parameters:
figsize: tuple = (12, 8)
dpi: int = 100
style: str = 'paper'
colormap: str = 'viridis'
line_alpha: float = 0.7
line_width: float = 1.5
grid: bool = True
legend: bool = True
title_fontsize: int = 14
label_fontsize: int = 12
tick_fontsize: int = 10
use_custom_fonts: bool = True
font_family: str = 'Arial'
colors: Optional[dict[str, str]] = None
max_legend_params: int = 4
sort_results: bool = True
__post_init__()[source]

Initialize default colors.

Return type:

None

__init__(figsize=(12, 8), dpi=100, style='paper', colormap='viridis', line_alpha=0.7, line_width=1.5, grid=True, legend=True, title_fontsize=14, label_fontsize=12, tick_fontsize=10, use_custom_fonts=True, font_family='Arial', colors=None, max_legend_params=4, sort_results=True)
Parameters:

Usage Examples

Basic Plotting

import mmpp as mp

# Load results
op = mp.open("/path/to/simulations")
results = op.find(solver=3)

# Create plots
results.plot("time", "my")
results.plot("B_ext", "frequency", comp="z")

Advanced Plotting Options

# Customize plot appearance
results.set_style("paper")

# Plot with custom parameters
results.plot(
    "time", "mx",
    figsize=(10, 6),
    title="Magnetization Evolution",
    xlabel="Time (ns)",
    ylabel="Mx Component"
)

Snapshot Visualization

# Create spatial snapshots
result = op[0]
result.matplotlib.snapshot(
    dset="m",
    z=5,
    t=-1,  # Last time step
    repeat=2
)