Visualize Data

EIS - Electrochemical Impedance Spectra

Bode Plot

bodePlotter(axes=None, frequencies=None, Z=None, impedanceAbsolute=None, phase=None, impedanceObject=None, zTogetherPhase=True, absPhase=True, argsImpedanceAxis={}, argsPhaseAxis={})

Plot of an impedance spectrum in Bode representation

If no axes are passed, a new figure is created. Here you can decide whether impedance and phase are to be displayed in the same plot. The figure object and the axis objects are always returned.

Either the complex impedance can be transferred with the parameter Z or impedance and phase can be transferred separately. The phase must be passed in radians, not in degrees. By default, the amount of the phase is displayed - this can be switched off.

With argsImpedanceAxis and argsPhaseAxis the appearance of the lines and the plot can be influenced. These values are dictionaries which are parameterised like the matplotlib plotting functions. The possible configurations can be found in the Matplotlib Line2D properties documentation.

The following code section shows the dictionaries with the default axis configuration, which can be overwritten and extended.

defaultImpedanceFormat = {"linestyle":'dashed',
                      "linewidth":1,
                      "marker":"o",
                      "markersize":5,
                      "fillstyle":"none",
                      "color":"blue"}

defaultPhaseFormat = {"linestyle":'dashed',
                        "linewidth":1,
                        "marker":"o",
                        "markersize":5,
                        "fillstyle":"none",
                        "color":"red"}

The application could look like the following example, in which two spectra are plotted in bode representation and a legend is added.

(fig, axes) = bodePlotter(None, frequencies, Z=firstImpedances)
(fig, axes) = bodePlotter(axes, frequencies, Z=secondImpedances,
                       argsImpedanceAxis={"color": "green"}, argsPhaseAxis={"marker": "x"})

(impedanceAxis, phaseAxis) = axes
impedanceAxis.legend(["first spectra", "second spectra"])

plt.show()

(fig, (impedanceAxis, phaseAxis)) = bodePlotter(impedanceObject=IsmImport(r"path/to/file"))

plt.show()
Parameters:
  • axes – Tuple of impedance and phase axis (impedanceAxis, phaseAxis). If None is passed, a new figure with corresponding axes is created.

  • frequencies – Array with the frequency points.

  • Z – Array with the complex impedances. Either the parameter Z must be passed or impedanceAbsolute and phase must be passed.

  • impedanceAbsolute – Array with the impedance absolute values. Either the parameter Z must be passed or impedanceAbsolute and phase must be passed.

  • phase – Array with the phase values in radians. Either the parameter Z must be passed or impedanceAbsolute and phase must be passed.

  • zTogetherPhase – If this parameter is True, impedance and phase are displayed in a plot. If False, impedance and phase are shown in separate subplots. This parameter only has meaning if the parameter axes is None.

  • absPhase – If True, the absolute value of the phase is displayed.

  • argsImpedanceAxis – Standard Matplotlib Line2D properties as dictionary, which are passed into the plotting functions, for example to adjust colours and line widths.

  • argsPhaseAxis

    Standard Matplotlib Line2D properties as dictionary, which are passed into the plotting functions, for example to adjust colours and line widths.

Returns:

A tuple with a figure and a tuple of axis objects is returned. figure, (impedanceAxis, phaseAxis)

Nyquist Plot

nyquistPlotter(ax=None, Z=None, impedanceAbsolute=None, phase=None, impedanceObject=None, frequenciesToAnnotate=None, minusNyquist=True, maximumAbsImpedance=None, argsNyquistAxis={})

Plot of an impedance spectrum in Nyquist representation

If no axis is passed, a new figure is created, otherwise, it is plotted on this axis. The figure object and the axis objects are always returned.

Either the complex impedance can be transferred with the parameter Z or impedance and phase can be transferred separately. The phase must be passed in radians, not in degrees. minusNyquist is True by default and the graph with conjugate complex data is displayed as a -Nyquist plot.

It is also possible to write text in the diagram, for example to label selected points in the Nyquist diagram with the frequency. The following is an excerpt from an application example.

annotations = []
for i in [0, 5, 15, 40, 44]:
    annotations.append([frequencies[i], Z[i], {"fontsize":8}])

(fig, ax) = nyquistPlotter(None, frequenciesToAnnotate=annotations, Z=Z, maximumAbsImpedance=0.005)
plt.show()

(fig, ax) = nyquistPlotter(None, frequenciesToAnnotate=annotations, Z=Z,
                        minusNyquist=False, maximumAbsImpedance=0.005)

(fig, ax) = nyquistPlotter(ax, Z=Z2,
                        argsNyquistAxis={"color": "blue", "marker": "x"},
                        minusNyquist=False, maximumAbsImpedance=0.005)
ax.legend(["first impedance Z1", "second impedance Z2"])
plt.show()

(fig, axes) = nyquistPlotter(impedanceObject=IsmImport(r"path/to/file"))

plt.show()
Parameters:
  • axes – Axis on which to plot or None.. If None is passed, a new figure with corresponding axes is created.

  • Z – Array with the complex impedances. Either the parameter Z must be passed or impedanceAbsolute and phase must be passed.

  • impedanceAbsolute – Array with the impedance absolute values. Either the parameter Z must be passed or impedanceAbsolute and phase must be passed.

  • phase – Array with the phase values in radians. Either the parameter Z must be passed or impedanceAbsolute and phase must be passed.

  • frequenciesToAnnotate – Points with labels in the diagram for frequencies, for example. [[text,Z,formattingDict],[],…] For formatting the points with the formattingDict can be found in the Matplotlib annotate documentation . This parameter can also be omitted and an array can be passed with text and complex impedance only.

  • minusNyquist – If this value is True, the imaginary part is displayed inverted -Nyquist plot. This is the default.

  • maximumAbsImpedance – Maximum absolute impedance up to which the data points are plotted.

  • argsNyquistAxis

    Standard Matplotlib Line2D properties as dictionary, which are passed into the plotting functions, for example to adjust colours and line widths.

Returns:

A tuple with a figure and a tuple of axis objects is returned. figure, nyquistAxis