Plots API¶
plots
¶
Publication-quality plotting functions for simulation results.
This module provides plotting utilities for various visualization types:
- Material permittivity spectra
- Frequency vs incident angle (kx-ω diagrams)
- Frequency vs azimuthal angle (β-ω diagrams)
- k-space dispersion (kx-ky isofrequency contours)
- Stokes parameter distributions
- Mueller matrix elements
All plots share a small set of styling helpers (see the _ prefixed
functions) for consistent, publication-ready figures with proper axis labels,
colorbars, and typography.
Classes:
-
PlotStyle–Manages consistent plotting styles across all figures.
Functions:
-
plot_permittivity–Plot real and imaginary parts of permittivity spectra.
-
plot_permittivity_tensor–Plot Re/Im of the diagonal permittivity components for any material.
-
plot_materials_gallery–Grid of Re(ε) vs frequency for every built-in material.
-
plot_poincare_sphere–Plot a Stokes trajectory on the Poincaré sphere (works for any scenario).
-
plot_mueller_azimuthal–Plot frequency vs azimuthal angle with publication styling.
-
plot_mueller_azimuthal_pair–Plot two azimuthal plots side-by-side for comparison.
-
plot_stokes_parameters–Plot all Stokes parameters and DOP in 2×3 grid.
-
plot_kx_frequency–Plot frequency vs parallel wavevector (kx) dispersion diagram.
-
plot_kx_frequency_pair–Plot two kx-frequency diagrams side-by-side.
-
plot_mueller_dispersion–Plot k-space dispersion in kx-ky coordinates at fixed frequency.
-
plot_mueller_dispersion_pair–Plot two k-space dispersion diagrams side-by-side.
PlotStyle
¶
Manages consistent plotting styles across all figures.
Methods:
-
initialize–Initialize global matplotlib parameters for consistent plotting style.
-
style_axis–Apply consistent styling to matplotlib axis.
initialize
staticmethod
¶
Initialize global matplotlib parameters for consistent plotting style.
Sets font family, sizes, tick parameters, and math text rendering for publication-quality plots.
Source code in hyperbolic_optics/plots.py
style_axis
staticmethod
¶
Apply consistent styling to matplotlib axis.
Parameters:
-
ax(Axes) –Matplotlib axes object to style
-
show_labels(bool, default:True) –Whether to show axis labels
Note
Sets tick width, length, direction, and padding.
Source code in hyperbolic_optics/plots.py
plot_permittivity
¶
Plot real and imaginary parts of permittivity spectra.
Parameters:
-
material(BaseMaterial) –Material object containing frequency array
-
eps_ext(ndarray) –Extraordinary permittivity (parallel to optical axis)
-
eps_ord(ndarray) –Ordinary permittivity (perpendicular to optical axis)
-
save_name(str | None, default:None) –Optional filename for saving (without extension)
Note
Creates two-panel plot with Re(ε) and Im(ε) vs frequency.
Source code in hyperbolic_optics/plots.py
plot_permittivity_tensor
¶
Plot Re/Im of the diagonal permittivity components for any material.
General over crystal class: uniaxial (xx == yy, distinct zz), biaxial (xx, yy, zz all distinct) and monoclinic (diagonal shown; off-diagonal coupling not drawn). Uses the material's own frequency grid.
Parameters:
-
material(BaseMaterial) –A material with its
frequencyarray set (e.g. any entry from :func:hyperbolic_optics.materials.list_materials). -
save_name(str | None, default:None) –Optional filename for saving (without extension).
Raises:
-
ValueError–If the material has no intrinsic frequency range.
Source code in hyperbolic_optics/plots.py
plot_materials_gallery
¶
Grid of Re(ε) vs frequency for every built-in material.
A quick visual check of the phonon parameters across the catalogue
(:func:hyperbolic_optics.materials.list_materials) — e.g. hBN's two bands,
MoO₃'s three, and the hyperbolic sign flips. ε_xx, ε_yy, ε_zz are drawn over
each material's default frequency range.
Parameters:
-
save_name(str | None, default:None) –Optional filename for saving (without extension).
Source code in hyperbolic_optics/plots.py
plot_poincare_sphere
¶
Plot a Stokes trajectory on the Poincaré sphere (works for any scenario).
Takes the output Stokes parameters from any scenario (e.g.
Mueller.get_stokes_parameters or Jones.get_stokes_parameters) and plots
the normalized state (S1, S2, S3)/S0 on the unit sphere — poles are right/
left circular, the equator is linear. All batch axes are flattened into the
point cloud, so it visualizes how polarization evolves across an incident-angle,
azimuthal, frequency or depth sweep.
Parameters:
-
stokes(dict[str, ndarray] | ndarray) –Either a dict with keys
S0, S1, S2, S3or an array[..., 4]. -
color_by(ndarray | None, default:None) –Optional array (any broadcastable shape) used to colour the points — e.g. frequency or sweep index. Defaults to point order.
-
title(str | None, default:None) –Optional plot title.
-
save_name(str | None, default:None) –Optional filename for saving (without extension).
Source code in hyperbolic_optics/plots.py
plot_mueller_azimuthal
¶
Plot frequency vs azimuthal angle with publication styling.
Parameters:
-
structure(Structure) –Structure object with azimuthal_angle and frequency arrays
-
param(ndarray) –2D parameter array to plot (typically reflectivity) [410, 360]
-
title(str | None, default:None) –Optional plot title
-
save_name(str | None, default:None) –Optional filename for saving (without extension)
-
label(str, default:'a') –Subplot label (e.g., 'a', 'b')
Note
Color plot with frequency on the y-axis and azimuthal angle (β) on the x-axis, for studying rotational anisotropy.
Source code in hyperbolic_optics/plots.py
plot_mueller_azimuthal_pair
¶
Plot two azimuthal plots side-by-side for comparison.
Parameters:
-
structure(Structure) –Structure object with angle and frequency data
-
param1(ndarray) –First parameter array [410, 360]
-
param2(ndarray) –Second parameter array [410, 360]
-
title1(str | None, default:None) –Title for left panel
-
title2(str | None, default:None) –Title for right panel
-
save_name(str | None, default:None) –Optional filename for saving
Note
Useful for comparing different polarizations or materials.
Source code in hyperbolic_optics/plots.py
plot_stokes_parameters
¶
Plot all Stokes parameters and DOP in 2×3 grid.
Parameters:
-
structure(Structure) –Structure object with angle and frequency arrays
-
params(dict[str, ndarray]) –Dictionary with S0, S1, S2, S3, DOP, Ellipticity keys
-
plot_type(str, default:'incidence') –'incidence' or 'azimuthal' to determine x-axis
-
save_name(str | None, default:None) –Optional filename for saving
Note
Creates comprehensive visualization of complete polarization state across parameter space.
Source code in hyperbolic_optics/plots.py
plot_kx_frequency
¶
Plot frequency vs parallel wavevector (kx) dispersion diagram.
Parameters:
-
structure(Structure) –Structure object with incident_angle, frequency, eps_prism
-
param(ndarray) –2D parameter array [410, 360]
-
title(str | None, default:None) –Optional plot title
-
rotation_y(float | None, default:None) –Optional rotation angle to display in plot
-
save_name(str | None, default:None) –Optional filename for saving
-
label(str, default:'a') –Subplot label
Note
Shows polariton dispersion with kx/k0 on x-axis and frequency on y-axis. Useful for identifying resonance branches.
Source code in hyperbolic_optics/plots.py
plot_kx_frequency_pair
¶
plot_kx_frequency_pair(structure, param1, param2, rotation_y1=None, rotation_y2=None, title1=None, title2=None, save_name=None)
Plot two kx-frequency diagrams side-by-side.
Parameters:
-
structure(Structure) –Structure object with dispersion data
-
param1(ndarray) –First parameter array
-
param2(ndarray) –Second parameter array
-
rotation_y1(float | None, default:None) –Rotation angle for first plot
-
rotation_y2(float | None, default:None) –Rotation angle for second plot
-
title1(str | None, default:None) –Title for left panel
-
title2(str | None, default:None) –Title for right panel
-
save_name(str | None, default:None) –Optional filename for saving
Source code in hyperbolic_optics/plots.py
plot_mueller_dispersion
¶
Plot k-space dispersion in kx-ky coordinates at fixed frequency.
Parameters:
-
structure(Structure) –Structure object with incident_angle, azimuthal_angle arrays
-
param(ndarray) –2D parameter array [180, 480]
-
title(str | None, default:None) –Optional plot title
-
rotation_y(float | None, default:None) –Optional rotation angle to display
-
save_name(str | None, default:None) –Optional filename for saving
-
label(str, default:'a') –Subplot label
Note
Shows isofrequency contours in momentum space. The unit circle indicates the light cone (k = k0); features outside are evanescent.
Source code in hyperbolic_optics/plots.py
plot_mueller_dispersion_pair
¶
plot_mueller_dispersion_pair(structure, param1, param2, rotation_y1=None, rotation_y2=None, title1=None, title2=None, save_name=None)
Plot two k-space dispersion diagrams side-by-side.
Parameters:
-
structure(Structure) –Structure object with dispersion data
-
param1(ndarray) –First parameter array [180, 480]
-
param2(ndarray) –Second parameter array [180, 480]
-
rotation_y1(float | None, default:None) –Rotation angle for first plot
-
rotation_y2(float | None, default:None) –Rotation angle for second plot
-
title1(str | None, default:None) –Title for left panel
-
title2(str | None, default:None) –Title for right panel
-
save_name(str | None, default:None) –Optional filename for saving
Note
Both plots share a colorbar and have unit circles indicating the light-cone boundary.