Plotting¶
Thermodynamic plots¶
plot_energy(source, *, ax=None)
¶
Plot energy per site vs temperature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
SimulationResults, path, or list of either
|
One or more result sets to plot. Lists produce overlaid curves. |
required |
ax
|
Axes
|
Matplotlib axes. Creates a new figure if None. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The matplotlib figure. |
plot_magnetization(source, *, ax=None)
¶
Plot |magnetization| per site vs temperature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
SimulationResults, path, or list of either
|
One or more result sets to plot. |
required |
ax
|
Axes
|
Matplotlib axes. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The matplotlib figure. |
plot_specific_heat(source, *, ax=None)
¶
Plot specific heat per site vs temperature.
Cv = N * Var(E) / T^2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
SimulationResults, path, or list of either
|
One or more result sets to plot. |
required |
ax
|
Axes
|
Matplotlib axes. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The matplotlib figure. |
plot_susceptibility(source, *, ax=None)
¶
Plot magnetic susceptibility per site vs temperature.
chi = N * Var(M) / T.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
SimulationResults, path, or list of either
|
One or more result sets to plot. |
required |
ax
|
Axes
|
Matplotlib axes. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The matplotlib figure. |
Lattice visualization¶
plot_lattice(source, *, temperature=None, n=None, max_cols=10, max_panels=100)
¶
Plot spin configuration(s) as heatmap(s).
With no n: shows all configurations at the given temperature
side by side in a grid. With n: shows a single configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
SimulationResults, path, or NDArray
|
Results object, HDF5 path, or a raw spin array. |
required |
temperature
|
float
|
Temperature to plot (required if source is Results/path). |
None
|
n
|
int
|
Specific configuration index (0-based). If None, shows all configurations at that temperature in a grid. |
None
|
max_cols
|
int
|
Maximum columns in the grid (when showing all configs). |
10
|
max_panels
|
int
|
Maximum panels before auto-subsampling with a warning. |
100
|
Returns:
| Type | Description |
|---|---|
Figure
|
The matplotlib figure. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
export_lattices(source, output, *, flat=False, temperatures=None, dpi=100)
¶
Export lattice configurations as PNG images in a zip file.
Each spin configuration is rendered as a heatmap and saved with a descriptive filename encoding lattice type, couplings, algorithm, temperature, and configuration index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
SimulationResults or path
|
Results with stored configurations. |
required |
output
|
str or Path
|
Output zip file path. |
required |
flat
|
bool
|
If False (default), organize in tree: folder per temperature. If True, all PNGs in one flat folder. |
False
|
temperatures
|
list[float]
|
Specific temperatures to export. If None, exports all. |
None
|
dpi
|
int
|
Resolution of exported images. |
100
|
Returns:
| Type | Description |
|---|---|
int
|
Number of images exported. |
Diagnostic plots¶
plot_energy_timeseries(source, temperature, *, ax=None)
¶
Plot the energy time series at a given temperature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
SimulationResults or path
|
Results with energy data. |
required |
temperature
|
float
|
Temperature to plot. |
required |
ax
|
Axes
|
Matplotlib axes. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The matplotlib figure. |
plot_magnetization_histogram(source, temperature, *, bins=50, ax=None)
¶
Plot the magnetization distribution at a given temperature.
Below Tc the distribution is bimodal (peaks at +/- M0). Above Tc it is a single Gaussian peak near zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
SimulationResults or path
|
Results with magnetization data. |
required |
temperature
|
float
|
Temperature to plot. |
required |
bins
|
int
|
Number of histogram bins. |
50
|
ax
|
Axes
|
Matplotlib axes. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The matplotlib figure. |
plot_correlation(source, temperature, *, ax=None)
¶
Plot the correlation function at a given temperature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
SimulationResults or path
|
Results with correlation data. |
required |
temperature
|
float
|
Temperature to plot. |
required |
ax
|
Axes
|
Matplotlib axes. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The matplotlib figure. |
Legacy¶
plot_observables(results, *, quantities=('energy', 'magnetization'))
¶
Plot observables vs temperature (legacy interface).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
SimulationResults
|
Simulation results. |
required |
quantities
|
tuple[str, ...]
|
Quantities to plot: 'energy', 'magnetization', 'specific_heat', 'susceptibility'. |
('energy', 'magnetization')
|
Returns:
| Type | Description |
|---|---|
Figure
|
The matplotlib figure. |