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:
- __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.PlotterProxy(results, mmpp_instance=None)[source]
Bases:
object
Proxy class to provide plotting functionality to search results.
- __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
- 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
- __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
- configure(**kwargs)[source]
Configure plot settings.
- Return type:
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:
Returns:
: MMPPlotter
Self for method chaining
- set_style(style_name)[source]
Set matplotlib style.
- Return type:
Parameters:
- style_namestr
Name of the matplotlib style
Returns:
: MMPPlotter
Self for method chaining
- param style_name:
- type style_name:
- get_available_styles()[source]
Get list of available matplotlib styles.
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:
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:
- param y_series:
- type y_series:
- param comp:
- type comp:
- param average:
- type average:
- param figsize:
- type figsize:
- param title:
- type title:
- param xlabel:
- type xlabel:
- param ylabel:
- type ylabel:
- param legend_labels:
- type legend_labels:
- param legend_variables:
- type legend_variables:
- param colors:
- type colors:
- param save_path:
- type save_path:
- param paper_ready:
- type paper_ready:
- param kwargs:
- type kwargs:
- plot_time_series(dataset, comp='z', average=(1, 2, 3), **kwargs)[source]
Convenience method for time series plotting.
- Return type:
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
- plot_components(dataset, time_slice=-1, average=(1, 2, 3), **kwargs)[source]
Plot all three components of a dataset.
- Return type:
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
- get_plot_data()[source]
Get data from the last plot for further analysis.
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:
Parameters:
- filenamestr
Output filename
- formatstr, optional
Format (‘npz’, ‘csv’, ‘json’)
- snapshot(dset=None, z=0, t=-1, ax=None, repeat=1, zero=None)[source]
Create a snapshot visualization of magnetization data.
- Return type:
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
- mmpp.plotting.hsl2rgb(hsl)[source]
Convert HSL color space to RGB.
- Return type:
Parameters:
- hslnp.ndarray
HSL color array with shape (…, 3)
Returns:
: np.ndarray
RGB color array with same shape
- param hsl:
- type hsl:
- mmpp.plotting.rgb2hsl(rgb)[source]
Convert RGB color space to HSL.
- Return type:
Parameters:
- rgbnp.ndarray
RGB color array with shape (…, 3)
Returns:
: np.ndarray
HSL color array with same shape
- param rgb:
- type rgb:
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
- __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
- configure(**kwargs)[source]
Configure plot settings.
- Return type:
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:
Returns:
: MMPPlotter
Self for method chaining
- set_style(style_name)[source]
Set matplotlib style.
- Return type:
Parameters:
- style_namestr
Name of the matplotlib style
Returns:
: MMPPlotter
Self for method chaining
- param style_name:
- type style_name:
- get_available_styles()[source]
Get list of available matplotlib styles.
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:
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:
- param y_series:
- type y_series:
- param comp:
- type comp:
- param average:
- type average:
- param figsize:
- type figsize:
- param title:
- type title:
- param xlabel:
- type xlabel:
- param ylabel:
- type ylabel:
- param legend_labels:
- type legend_labels:
- param legend_variables:
- type legend_variables:
- param colors:
- type colors:
- param save_path:
- type save_path:
- param paper_ready:
- type paper_ready:
- param kwargs:
- type kwargs:
- plot_time_series(dataset, comp='z', average=(1, 2, 3), **kwargs)[source]
Convenience method for time series plotting.
- Return type:
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
- plot_components(dataset, time_slice=-1, average=(1, 2, 3), **kwargs)[source]
Plot all three components of a dataset.
- Return type:
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
- get_plot_data()[source]
Get data from the last plot for further analysis.
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:
Parameters:
- filenamestr
Output filename
- formatstr, optional
Format (‘npz’, ‘csv’, ‘json’)
- snapshot(dset=None, z=0, t=-1, ax=None, repeat=1, zero=None)[source]
Create a snapshot visualization of magnetization data.
- Return type:
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
PlotterProxy
- class mmpp.plotting.PlotterProxy(results, mmpp_instance=None)[source]
Bases:
object
Proxy class to provide plotting functionality to search results.
- __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
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:
- __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
)