Plotting¶
API Reference¶
-
impedancefitter.plotting.emcee_plot(res, clustered=False, **corner_kwargs)[source]¶ Create corner plot.
- Parameters
res (dict) – Dictionary containing values and flatchain
corner_kwargs (dict, optional) – Dictionary with further corner plot options
-
impedancefitter.plotting.plot_admittance(omega, Z, title='', Z_fit=None, show=True, save=False, Z_comp=None, labels=['Data', 'Best fit', 'Init fit'], residual='parts', sign=False, Zlog=False, append=False, limits_residual=None, omega_fit=None, omega_comp=None, legend=True, compare=True)[source]¶ Plot the admittance and compare it to data 1/Z.
Generates 4 subplots showing the real and imaginary parts over the frequency; a Nyquist plot of real and negative imaginary part and the relative differences of real and imaginary part as well as absolute value of admittance.
- Parameters
omega (
numpy.ndarray, double) – Frequency arrayZ (
numpy.ndarray, complex) – Impedance array, experimental data or data to compare to.Z_fit (
numpy.ndarray, complex) – Impedance array, fit result. If provided, the difference between data and fit will be shown.title (str) – Title of plot.
show (bool, optional) – Show figure (default is True).
save (bool, optional) – Save figure to pdf (default is False). Name of figure starts with title and ends with _admittance_overview.pdf.
Z_comp (
numpy.ndarray, complex, optional) – Complex-valued impedance array. Might be used to compare the properties of two data sets.labels (list) – List of labels for three plots. Must have length 3 always. Is ordered like: [Z, Z_fit, Z_comp]
residual (str) – Plot relative difference w.r.t. real and imaginary part if parts. Plot relative difference w.r.t. absolute value if absolute. Plot difference (residual) if diff.
sign (bool, optional) – Use sign of residual. Default is False, i.e. absolute value is plotted.
Zlog (bool, optional) – Log-scale of impedance
append (bool, optional) – Decide if you want to show plot or add line to existing plot.
omega_fit (
numpy.ndarray, double, optional) – Frequency array, provide only if fitted impedance was evaluated at different frequencies than the experimental dataomega_comp (
numpy.ndarray, double, optional) – Frequency array, provide only if fitted impedance was evaluated at different frequencies than the experimental datalegend (str, optional) – Choose if a legend should be shown. Recommended to switch to False when using large datasets.
compare (bool, optional) – Choose if the difference between fit and data should be computed.
-
impedancefitter.plotting.plot_bode(omega, Z, title='', Z_fit=None, show=True, save=False, Z_comp=None, labels=['Data', 'Best fit', 'Init fit'], append=False, legend=True)[source]¶ Bode plot of impedance.
Plots phase and log of magnitude over log of frequency.
- Parameters
omega (
numpy.ndarray, double) – Frequency arrayZ (
numpy.ndarray, complex) – Impedance array, experimental data or data to compare to.Z_fit (
numpy.ndarray, complex) – Impedance array, fit result. If provided, the difference between data and fit will be shown.title (str) – Title of plot.
show (bool, optional) – Show figure (default is True).
save (bool, optional) – Save figure to pdf (default is False). Name of figure starts with title.
Z_comp (
numpy.ndarray, complex, optional) – Complex-valued impedance array. Might be used to compare the properties of two data sets.labels (list) – List of labels for three plots. Must have length 3 always. Is ordered like: [Z, Z_fit, Z_comp]
save (bool, optional) – save figure to pdf (default is False). Name of figure starts with title and ends with _bode_plot.pdf.
append (bool, optional) – Decide if you want to show plot or add line to existing plot.
legend (str, optional) – Choose if a legend should be shown. Recommended to switch to False when using large datasets.
-
impedancefitter.plotting.plot_cole_cole(omega, Z, c0, Z_comp=None, append=False, legend=True, markers=[None, None], title='', show=True, save=False, labels=None, limits=None)[source]¶ - Parameters
omega (
numpy.ndarray, double) – frequency arrayZ (
numpy.ndarray, complex) – impedance arrayc0 (double) – unit capacitance of device
Z_comp (
numpy.ndarray, complex, optional) – complex-valued impedance array. Might be used to compare the properties of two data sets.title (str, optional) – title of plot. Default is an empty string.
show (bool, optional) – show figure (default is True)
save (bool, optional) – save figure to pdf (default is False). Name of figure starts with title and ends with _dielectric_properties.pdf.
logscale (str, optional) – Decide what you want to plot using log scale. Possible are permittivity, conductivity and both
labels (list, optional) – Give custom labels. Needs to be a list of length 2.
-
impedancefitter.plotting.plot_compare_to_data(omega, Z, Z_fit, subplot=None, title='', show=True, save=False, residual='parts', sign=False, limits=None, impedance_threshold=1.0, legend=True, **plotkwargs)[source]¶ plots the difference of the fitted function to the data
- Parameters
omega (
numpy.ndarray, double) – frequency arrayZ (
numpy.ndarray, complex) – impedance array, experimental data or data to compare toZ_fit (
numpy.ndarray, complex) – impedance array, fit resultsubplot (optional) – decide whether it is a new figure or a subplot. Default is None (yields new figure). Otherwise it can be an integer to denote the subfigure.
title (str, optional) – title of plot. Default is an empty string.
show (bool, optional) – show figure (default is True). Only has an effect when subplot is None.
save (bool, optional) – save figure to pdf (default is False). Name of figure starts with title and ends with _relative_difference_to_data.pdf or _difference_to_data.pdf.
relative (str, optional) – Plot relative difference if True, else plot residual (i.e. just difference).
sign (bool, optional) – Use sign of residual. Default is False, i.e. absolute value is plotted.
residual (str) – Plot relative difference w.r.t. real and imaginary part if parts. Plot relative difference w.r.t. absolute value if absolute. Plot difference (residual) if diff.
limits (list, optional) – List with entries [bottom, top] for y-axis of residual plot.
impedance_threshold (double, optional) – Threshold for impedance around 0, which is disregarded in the relative differences plot. Default is that impedances, with an absolute value less than 0 are not considered.
legend (str, optional) – Choose if a legend should be shown. Recommended to switch to False when using large datasets.
Notes
When computing the relative difference, impedances between -1 and 1 Ohm are not considered since they might lead to a blow up of the relative difference (close to division by 0). Instead of this quantitative measure, qualitative checks should be done.
-
impedancefitter.plotting.plot_comparison_dielectric_properties(omega, Z, c0, Z_comp, title='', show=True, save=False, residual='relative', label=None, append=False, marker=None, legend=True, limits=None, **plotkwargs)[source]¶ - Parameters
omega (
numpy.ndarray, double) – frequency arrayZ (
numpy.ndarray, complex) – impedance arrayc0 (double) – unit capacitance of device
Z_comp (
numpy.ndarray, complex) – complex-valued impedance array to compare the properties of two data sets.title (str, optional) – title of plot. Default is an empty string.
show (bool, optional) – show figure (default is True)
save (bool, optional) – save figure to pdf (default is False). Name of figure starts with title and ends with _dielectric_properties.pdf.
logscale (str, optional) – Decide what you want to plot using log scale. Possible are permittivity, conductivity and both
label (str, optional) – Give custom label. Needs to be a str.
append (bool, optional) – Decide if you want to show plot or add line to existing plot.
legend (bool, optional) – Switch legend on/off
-
impedancefitter.plotting.plot_complex_permittivity(omega, Z, c0, Z_comp=None, title='', show=True, save=False, logscale='permittivity', labels=None)[source]¶ - Parameters
omega (
numpy.ndarray, double) – frequency arrayZ (
numpy.ndarray, complex) – impedance arrayc0 (double) – unit capacitance of device
Z_comp (
numpy.ndarray, complex, optional) – complex-valued impedance array. Might be used to compare the properties of two data sets.title (str, optional) – title of plot. Default is an empty string.
show (bool, optional) – show figure (default is True)
save (bool, optional) – save figure to pdf (default is False). Name of figure starts with title and ends with _dielectric_properties.pdf.
logscale (str, optional) – Decide what you want to plot using log scale. Possible are permittivity, loss and both
labels (list, optional) – Give custom labels. Needs to be a list of length 2.
-
impedancefitter.plotting.plot_dielectric_dispersion(omega, Z, c0, Z_comp=None, title='', show=True, save=False, logscale='permittivity', labels=None, **plotkwargs)[source]¶ - Parameters
omega (
numpy.ndarray, double) – frequency arrayZ (
numpy.ndarray, complex) – impedance arrayc0 (double) – unit capacitance of device
Z_comp (
numpy.ndarray, complex, optional) – complex-valued impedance array. Might be used to compare the properties of two data sets.title (str, optional) – title of plot. Default is an empty string.
show (bool, optional) – show figure (default is True)
save (bool, optional) – save figure to pdf (default is False). Name of figure starts with title and ends with _dielectric_properties.pdf.
logscale (str, optional) – Decide what you want to plot using log scale. Possible are permittivity, conductivity and both
labels (list, optional) – Give custom labels. Needs to be a list of length 2.
-
impedancefitter.plotting.plot_dielectric_modulus(omega, Z, c0, Z_comp=None, title='', show=True, save=False, logscale=None, labels=None)[source]¶ - Parameters
omega (
numpy.ndarray, double) – frequency arrayZ (
numpy.ndarray, complex) – impedance arrayc0 (double) – unit capacitance of device
Z_comp (
numpy.ndarray, complex, optional) – complex-valued impedance array. Might be used to compare the properties of two data sets.title (str, optional) – title of plot. Default is an empty string.
show (bool, optional) – show figure (default is True)
save (bool, optional) – save figure to pdf (default is False). Name of figure starts with title and ends with _dielectric_properties.pdf.
logscale (str, optional) – Decide what you want to plot using log scale. Possible are ReM, ImM and both
labels (list, optional) – Give custom labels. Needs to be a list of length 2.
-
impedancefitter.plotting.plot_dielectric_properties(omega, Z, c0, Z_comp=None, title='', show=True, save=False, logscale='permittivity', labels=None, append=False, markers=[None, None], legend=True, limits=None, **plotkwargs)[source]¶ - Parameters
omega (
numpy.ndarray, double) – frequency arrayZ (
numpy.ndarray, complex) – impedance arrayc0 (double) – unit capacitance of device
Z_comp (
numpy.ndarray, complex, optional) – complex-valued impedance array. Might be used to compare the properties of two data sets.title (str, optional) – title of plot. Default is an empty string.
show (bool, optional) – show figure (default is True)
save (bool, optional) – save figure to pdf (default is False). Name of figure starts with title and ends with _dielectric_properties.pdf.
logscale (str, optional) – Decide what you want to plot using log scale. Possible are permittivity, conductivity and both
labels (list, optional) – Give custom labels. Needs to be a list of length 2.
append (bool, optional) – Decide if you want to show plot or add line to existing plot.
legend (bool, optional) – Switch legend on/off
-
impedancefitter.plotting.plot_impedance(omega, Z, title='', Z_fit=None, show=True, save=False, Z_comp=None, labels=['Data', 'Best fit', 'Init fit'], residual='parts', sign=False, Zlog=False, append=False, limits_residual=None, omega_fit=None, omega_comp=None, legend=True, compare=True, **plotkwargs)[source]¶ Plot the result and compare it to data Z.
Generates 4 subplots showing the real and imaginary parts over the frequency; a Nyquist plot of real and negative imaginary part and the relative differences of real and imaginary part as well as absolute value of impedance.
- Parameters
omega (
numpy.ndarray, double) – Frequency arrayZ (
numpy.ndarray, complex) – Impedance array, experimental data or data to compare to.Z_fit (
numpy.ndarray, complex) – Impedance array, fit result. If provided, the difference between data and fit will be shown.title (str) – Title of plot.
show (bool, optional) – Show figure (default is True).
save (bool, optional) – Save figure to pdf (default is False). Name of figure starts with title and ends with _impedance_overview.pdf.
Z_comp (
numpy.ndarray, complex, optional) – Complex-valued impedance array. Might be used to compare the properties of two data sets.labels (list) – List of labels for three plots. Must have length 3 always. Is ordered like: [Z, Z_fit, Z_comp]
residual (str) – Plot relative difference w.r.t. real and imaginary part if parts. Plot relative difference w.r.t. absolute value if absolute. Plot difference (residual) if diff.
sign (bool, optional) – Use sign of residual. Default is False, i.e. absolute value is plotted.
Zlog (bool, optional) – Log-scale of impedance
append (bool, optional) – Decide if you want to show plot or add line to existing plot.
omega_fit (
numpy.ndarray, double, optional) – Frequency array, provide only if fitted impedance was evaluated at different frequencies than the experimental dataomega_comp (
numpy.ndarray, double, optional) – Frequency array, provide only if fitted impedance was evaluated at different frequencies than the experimental datalegend (str, optional) – Choose if a legend should be shown. Recommended to switch to False when using large datasets.
compare (bool, optional) – Choose if the difference between fit and data should be computed.
-
impedancefitter.plotting.plot_resistance_capacitance(omega, Z, title='', Z_fit=None, show=True, save=False, Z_comp=None, labels=['Data', 'Best fit', 'Init fit'], append=False, legend=True)[source]¶ R-C plot of impedance.
Plots phase and log of magnitude over log of frequency.
- Parameters
omega (
numpy.ndarray, double) – Frequency arrayZ (
numpy.ndarray, complex) – Impedance array, experimental data or data to compare to.Z_fit (
numpy.ndarray, complex) – Impedance array, fit result. If provided, the difference between data and fit will be shown.title (str) – Title of plot.
show (bool, optional) – Show figure (default is True).
save (bool, optional) – Save figure to pdf (default is False). Name of figure starts with title.
Z_comp (
numpy.ndarray, complex, optional) – Complex-valued impedance array. Might be used to compare the properties of two data sets.labels (list) – List of labels for three plots. Must have length 3 always. Is ordered like: [Z, Z_fit, Z_comp]
save (bool, optional) – save figure to pdf (default is False). Name of figure starts with title and ends with _bode_plot.pdf.
append (bool, optional) – Decide if you want to show plot or add line to existing plot.
legend (str, optional) – Choose if a legend should be shown. Recommended to switch to False when using large datasets.
-
impedancefitter.plotting.plot_uncertainty(omega, Zdata, Z, Z1, Z2, sigma, show=True, model=None)[source]¶ Plot best fit with uncertainty interval.
- Parameters
Zdata (
numpy.ndarray, complex) – impedance array of experimental dataZ (
numpy.ndarray, complex) – impedance array of best fitZ1 (
numpy.ndarray, complex) – impedance array of upper uncertainty limitZ2 (
numpy.ndarray, complex) – impedance array of lower uncertainty limitsigma (double) – confidence level
show (bool, optional) – show figure (default is True)
model (int, optional) – numbering of model for sequential plotting