defectpl.plot¶
Plotter
¶
Publication-quality static figure generator for DefectPL outputs.
Each method produces a single matplotlib figure and either displays it
interactively (plot=True) or saves it at 600 dpi to out_dir
(plot=False, the default used by :meth:~defectpl.defectpl.Photoluminescence.generate_plots).
All energy inputs follow the internal convention of eV; axis labels are converted to meV where appropriate for readability.
Methods:
| Name | Description |
|---|---|
plot_penergy_vs_pmode |
Phonon energy vs mode index (dispersionless Γ-point spectrum). |
plot_ipr_vs_penergy |
Phonon IPR vs phonon energy. |
plot_loc_rat_vs_penergy |
Localization ratio β_k = N·IPR_k vs phonon energy. |
plot_qk_vs_penergy |
Mode-projected displacement q_k vs phonon energy. |
plot_HR_factor_vs_penergy |
Partial Huang–Rhys factors S_k vs phonon energy. |
plot_S_omega_vs_penergy |
Continuous spectral density S(ω) vs phonon energy. |
plot_S_omega_Sks_vs_penergy |
S(ω) and S_k overlaid on dual y-axes. |
plot_S_omega_Sks_Loc_rat_vs_penergy |
S(ω) + S_k scatter coloured by localization ratio. |
plot_S_omega_Sks_ipr_vs_penergy |
S(ω) + S_k scatter coloured by IPR (traditional convention). |
plot_ipr_alkauskas_vs_penergy |
Phonon IPR (Alkauskas eq. 12 convention) vs phonon energy. |
plot_S_omega_Sks_ipr_alkauskas_vs_penergy |
S(ω) + S_k scatter coloured by Alkauskas IPR. |
plot_nk_vs_penergy |
Bose-Einstein phonon occupation n̄_k(T) vs phonon energy. |
plot_C_omega_vs_penergy |
Thermal spectral density C(ℏω, T) vs phonon energy. |
plot_intensity_vs_penergy |
Normalised PL intensity spectrum vs photon energy. |
plot_absorption_vs_penergy |
Normalised absorption spectrum vs photon energy. |
plot_pl_absorption_vs_penergy |
PL and absorption overlaid on the same axes. |
plot_penergy_vs_pmode
¶
plot_penergy_vs_pmode(frequencies, plot=False, out_dir='./', file_name='penergy_vs_pmode', fig_format='pdf', figsize=(3.3, 2.5))
Plot phonon energy (meV) vs mode index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
(ndarray, shape(nmodes))
|
Phonon frequencies in eV. |
required |
plot
|
bool
|
Show interactively instead of saving. Default False. |
False
|
out_dir
|
str or Path
|
Output directory. Default |
'./'
|
file_name
|
str
|
Base file name (no extension). Default |
'penergy_vs_pmode'
|
fig_format
|
str
|
|
'pdf'
|
figsize
|
tuple of float
|
Figure size in inches. Default |
(3.3, 2.5)
|
Source code in defectpl/plot.py
plot_ipr_vs_penergy
¶
plot_ipr_vs_penergy(frequencies, iprs, plot=False, out_dir='./', file_name='ipr_vs_penergy', fig_format='pdf', figsize=(3.3, 2.5))
Scatter plot of phonon IPR vs phonon energy (meV).
IPR = Σp²/(Σp)² ranges from 1/N (fully delocalized) to 1 (fully localized).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
(ndarray, shape(nmodes))
|
Phonon frequencies in eV. |
required |
iprs
|
(ndarray, shape(nmodes))
|
Inverse participation ratios per mode. |
required |
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_loc_rat_vs_penergy
¶
plot_loc_rat_vs_penergy(frequencies, localization_ratio, plot=False, out_dir='./', file_name='loc_rat_vs_penergy', fig_format='pdf', figsize=(3.3, 2.5))
Scatter plot of localization ratio β_k = N·IPR_k vs phonon energy (meV).
β = 1 means perfectly delocalized; β = N means fully localized on one atom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
(ndarray, shape(nmodes))
|
Phonon frequencies in eV. |
required |
localization_ratio
|
(ndarray, shape(nmodes))
|
Localization ratio per mode. |
required |
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_qk_vs_penergy
¶
plot_qk_vs_penergy(frequencies, qks, plot=False, out_dir='./', file_name='qk_vs_penergy', fig_format='pdf', figsize=(3.3, 2.5))
Scatter plot of mode-projected displacement q_k vs phonon energy (meV).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
(ndarray, shape(nmodes))
|
Phonon frequencies in eV. |
required |
qks
|
(ndarray, shape(nmodes))
|
Mode configurational displacements in amu^(½)·Å. |
required |
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_HR_factor_vs_penergy
¶
plot_HR_factor_vs_penergy(frequencies, Sks, plot=False, out_dir='./', file_name='HR_factor_vs_penergy', fig_format='pdf', figsize=(3.3, 2.5))
Scatter plot of partial Huang–Rhys factors S_k vs phonon energy (meV).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
(ndarray, shape(nmodes))
|
Phonon frequencies in eV. |
required |
Sks
|
(ndarray, shape(nmodes))
|
Partial (mode-resolved) Huang–Rhys factors. |
required |
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_S_omega_vs_penergy
¶
plot_S_omega_vs_penergy(frequencies, S_omega, omega_range, plot=False, out_dir='./', file_name='S_omega_vs_penergy', max_freq=None, fig_format='pdf', figsize=(3.3, 2.5))
Line plot of the continuous Huang–Rhys spectral density S(ω) in 1/meV vs energy (meV).
S(ω) is the phonon sideband weight per unit energy; its integral equals the total Huang–Rhys factor S.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
(ndarray, shape(nmodes))
|
Phonon frequencies in eV (used to set x-axis upper limit). |
required |
S_omega
|
(array - like, shape(n_grid))
|
Spectral density in eV^(-1). |
required |
omega_range
|
list[ω_min, ω_max, n_points]
|
Energy grid parameters in eV matching the S(ω) array. |
required |
max_freq
|
float
|
Upper frequency cut-off for the plot in eV. |
None
|
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_S_omega_Sks_vs_penergy
¶
plot_S_omega_Sks_vs_penergy(frequencies, S_omega, omega_range, Sks, plot=False, out_dir='./', file_name='S_omega_Sks_vs_penergy', max_freq=None, fig_format='pdf', figsize=(3.5, 2.5))
Dual-axis plot of S(ω) (left axis) and partial S_k scatter (right axis).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
ndarray
|
See :meth: |
required |
S_omega
|
ndarray
|
See :meth: |
required |
omega_range
|
ndarray
|
See :meth: |
required |
Sks
|
(ndarray, shape(nmodes))
|
Partial Huang–Rhys factors. |
required |
max_freq
|
float
|
Upper frequency cut-off in eV. |
None
|
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_S_omega_Sks_Loc_rat_vs_penergy
¶
plot_S_omega_Sks_Loc_rat_vs_penergy(frequencies, S_omega, omega_range, Sks, localization_ratio, plot=False, out_dir='./', file_name='S_omega_HRf_loc_rat_vs_penergy', max_freq=None, pylim=[None, None], fig_format='pdf', figsize=(4.2, 2.5), cmap='viridis')
S(ω) line + S_k scatter coloured by localization ratio β_k.
Identifies phonon modes that simultaneously carry large HR weight and are localized near the defect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
ndarray
|
See :meth: |
required |
S_omega
|
ndarray
|
See :meth: |
required |
omega_range
|
ndarray
|
See :meth: |
required |
Sks
|
(ndarray, shape(nmodes))
|
Partial Huang–Rhys factors (right y-axis). |
required |
localization_ratio
|
(ndarray, shape(nmodes))
|
Colour-code values β_k = N·IPR_k. |
required |
pylim
|
list of [float or None, float or None]
|
|
[None, None]
|
cmap
|
str
|
Matplotlib colormap name. Default |
'viridis'
|
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_S_omega_Sks_ipr_vs_penergy
¶
plot_S_omega_Sks_ipr_vs_penergy(frequencies, S_omega, omega_range, Sks, iprs, plot=False, out_dir='./', file_name='S_omega_HRf_ipr_vs_penergy', max_freq=None, fig_format='pdf', figsize=(4.2, 2.5), cmap='viridis')
S(ω) line + S_k scatter coloured by phonon IPR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
ndarray
|
See :meth: |
required |
S_omega
|
ndarray
|
See :meth: |
required |
omega_range
|
ndarray
|
See :meth: |
required |
Sks
|
(ndarray, shape(nmodes))
|
Partial Huang–Rhys factors (right y-axis). |
required |
iprs
|
(ndarray, shape(nmodes))
|
Phonon inverse participation ratios used as colour code. |
required |
cmap
|
str
|
Matplotlib colormap name. Default |
'viridis'
|
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_ipr_alkauskas_vs_penergy
¶
plot_ipr_alkauskas_vs_penergy(frequencies, iprs_alkauskas, plot=False, out_dir='./', file_name='ipr_alkauskas_vs_penergy', fig_format='pdf', figsize=(3.3, 2.5))
Scatter plot of phonon IPR (Alkauskas eq. 12 convention) vs phonon energy (meV).
IPR_k = (Σp)²/Σp² ranges from 1 (fully localized) to N (fully delocalized).
This is the reciprocal of the traditional IPR plotted by :meth:plot_ipr_vs_penergy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
(ndarray, shape(nmodes))
|
Phonon frequencies in eV. |
required |
iprs_alkauskas
|
(ndarray, shape(nmodes))
|
Alkauskas-convention IPR per mode (Alkauskas 2014, eq. 12). |
required |
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_S_omega_Sks_ipr_alkauskas_vs_penergy
¶
plot_S_omega_Sks_ipr_alkauskas_vs_penergy(frequencies, S_omega, omega_range, Sks, iprs_alkauskas, plot=False, out_dir='./', file_name='S_omega_HRf_ipr_alkauskas_vs_penergy', max_freq=None, fig_format='pdf', figsize=(4.2, 2.5), cmap='viridis')
S(ω) line + S_k scatter coloured by Alkauskas-convention phonon IPR.
Modes with low IPR_k (close to 1) are localized; modes with high IPR_k (close to N) are bulk-like delocalized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
ndarray
|
See :meth: |
required |
S_omega
|
ndarray
|
See :meth: |
required |
omega_range
|
ndarray
|
See :meth: |
required |
Sks
|
(ndarray, shape(nmodes))
|
Partial Huang–Rhys factors (right y-axis). |
required |
iprs_alkauskas
|
(ndarray, shape(nmodes))
|
Alkauskas-convention IPR per mode used as colour code. |
required |
cmap
|
str
|
Matplotlib colormap name. Default |
'viridis'
|
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_intensity_vs_penergy
¶
plot_intensity_vs_penergy(frequencies, I, resolution, xlim, plot=False, out_dir='./', file_name='intensity_vs_penergy', iylim=None, fig_format='pdf', figsize=(3.3, 2.5))
Line plot of the normalised PL intensity spectrum vs photon energy (eV).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
ndarray
|
Phonon frequencies in eV (unused directly; kept for API consistency). |
required |
I
|
ndarray
|
Complex or real intensity array from :func: |
required |
resolution
|
int
|
Number of grid points per eV; sets the energy-axis scale. |
required |
xlim
|
tuple of float
|
|
required |
iylim
|
tuple of float
|
|
None
|
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_nk_vs_penergy
¶
plot_nk_vs_penergy(frequencies, nks, temperature=0.0, plot=False, out_dir='./', file_name='nk_vs_penergy', fig_format='pdf', figsize=(3.3, 2.5))
Scatter plot of Bose-Einstein phonon occupation n̄_k(T) vs phonon energy (meV).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
(ndarray, shape(nmodes))
|
Phonon frequencies in eV. |
required |
nks
|
(ndarray, shape(nmodes))
|
Bose-Einstein occupation numbers per mode. |
required |
temperature
|
float
|
Temperature in K, displayed in the axis label. Default 0. |
0.0
|
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_C_omega_vs_penergy
¶
plot_C_omega_vs_penergy(frequencies, C_omega, omega_range, plot=False, out_dir='./', file_name='C_omega_vs_penergy', max_freq=None, fig_format='pdf', figsize=(3.3, 2.5))
Line plot of the thermal spectral density C(ℏω, T) in 1/meV vs energy (meV).
C(ω, T) = Σ_k n̄_k(T) S_k δ(ℏω − ℏω_k) broadened with Gaussians. At T = 0 this plot is a flat zero line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
(ndarray, shape(nmodes))
|
Phonon frequencies in eV. |
required |
C_omega
|
(array - like, shape(n_grid))
|
Thermal spectral density in eV^(-1). |
required |
omega_range
|
list[ω_min, ω_max, n_points]
|
Energy grid parameters in eV. |
required |
max_freq
|
float
|
Upper frequency cut-off in eV. |
None
|
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_absorption_vs_penergy
¶
plot_absorption_vs_penergy(frequencies, absorption, resolution, xlim, plot=False, out_dir='./', file_name='absorption_vs_penergy', iylim=None, fig_format='pdf', figsize=(3.3, 2.5))
Line plot of the normalised absorption spectrum vs photon energy (eV).
The sideband lies on the high-energy side of the ZPL (phonon absorption raises the photon energy), opposite to PL emission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
ndarray
|
Phonon frequencies in eV (unused directly; kept for API consistency). |
required |
absorption
|
ndarray
|
Complex or real absorption array from
:func: |
required |
resolution
|
int
|
Number of grid points per eV. |
required |
xlim
|
tuple of float
|
|
required |
iylim
|
tuple of float
|
|
None
|
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|
Source code in defectpl/plot.py
plot_pl_absorption_vs_penergy
¶
plot_pl_absorption_vs_penergy(frequencies, intensity, absorption, resolution, xlim, plot=False, out_dir='./', file_name='pl_absorption_vs_penergy', fig_format='pdf', figsize=(3.3, 2.5))
Overlay of normalised PL (solid) and absorption (dashed) spectra.
Displays the Stokes shift between the PL emission peak and the absorption onset on a shared photon-energy axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
ndarray
|
Phonon frequencies in eV (unused directly; kept for API consistency). |
required |
intensity
|
ndarray
|
PL intensity array from :func: |
required |
absorption
|
ndarray
|
Absorption array from :func: |
required |
resolution
|
int
|
Number of grid points per eV. |
required |
xlim
|
tuple of float
|
|
required |
plot
|
bool
|
See :meth: |
False
|
out_dir
|
bool
|
See :meth: |
False
|
file_name
|
bool
|
See :meth: |
False
|
fig_format
|
bool
|
See :meth: |
False
|
figsize
|
bool
|
See :meth: |
False
|