diff --git a/mbtrack2/impedance/impedance_model.py b/mbtrack2/impedance/impedance_model.py index 223b634f05d0812858cdaeb6f8f1421cfc30aef6..ebc7b09debed36521c310dd2884f296260d4cce7 100644 --- a/mbtrack2/impedance/impedance_model.py +++ b/mbtrack2/impedance/impedance_model.py @@ -5,6 +5,7 @@ Module where the ImpedanceModel class is defined. import pandas as pd import numpy as np import matplotlib.pyplot as plt +from matplotlib import colormaps import pickle from copy import deepcopy from scipy.integrate import trapz @@ -249,11 +250,11 @@ class ImpedanceModel(): # manage legend Ztype_dict = {"Zlong":0, "Zxdip":1, "Zydip":2, "Zxquad":3, "Zyquad":4} scale = [1e-3, 1e-6, 1e-6, 1e-6, 1e-6] - label_list = [r"$Z_{long} \; [k\Omega]$", - r"$\frac{1}{\beta_0} \sum_{j} \beta_{x,j} Z_{x,j}^{Dip} \; [M\Omega/m]$", - r"$\frac{1}{\beta_0} \sum_{j} \beta_{y,j} Z_{y,j}^{Dip} \; [M\Omega/m]$", - r"$\frac{1}{\beta_0} \sum_{j} \beta_{x,j} Z_{x,j}^{Quad} \; [M\Omega/m]$", - r"$\frac{1}{\beta_0} \sum_{j} \beta_{y,j} Z_{y,j}^{Quad} \; [M\Omega/m]$"] + label_list = [r"$Z_\mathrm{long} \; (\mathrm{k}\Omega)$", + r"$\frac{1}{\beta_0} \sum_{j} \beta_{x,j} Z_{x,j}^\mathrm{Dip} \; (\mathrm{M}\Omega/\mathrm{m})$", + r"$\frac{1}{\beta_0} \sum_{j} \beta_{y,j} Z_{y,j}^\mathrm{Dip} \; (\mathrm{M}\Omega/\mathrm{m})$", + r"$\frac{1}{\beta_0} \sum_{j} \beta_{x,j} Z_{x,j}^\mathrm{Quad} \; (\mathrm{M}\Omega/\mathrm{m})$", + r"$\frac{1}{\beta_0} \sum_{j} \beta_{y,j} Z_{y,j}^\mathrm{Quad} \; (\mathrm{M}\Omega/\mathrm{m})$"] leg = Ztype_dict[Z_type] # sort plot by decresing area size @@ -277,13 +278,14 @@ class ImpedanceModel(): legend.append("Spectral density for sigma = " + str(sigma) + " s") # Main plot + colorblind = colormaps['tab10'].colors for index in sorted_index: attr = attr_list[index] # Set all impedances with common indexes using + zero_impedance try: sum_imp = getattr(getattr(self, attr), Z_type) + zero_impedance ax.fill_between(sum_imp.data.index*1e-9, total_imp, - total_imp + sum_imp.data[component]*scale[leg]) + total_imp + sum_imp.data[component]*scale[leg], edgecolor=colorblind[index%10], color=colorblind[index%10]) total_imp += sum_imp.data[component]*scale[leg] if attr[:4] == "sum_": legend.append(attr[4:]) @@ -297,8 +299,8 @@ class ImpedanceModel(): spect = spect/spect.max()*total_imp.max() ax.plot(sum_imp.data.index*1e-9, spect, 'r', linewidth=2.5) - ax.legend(legend, loc="upper left", ncol=3) - ax.set_xlabel("Frequency [GHz]") + ax.legend(legend, loc="upper left", ncol=2) + ax.set_xlabel("Frequency (GHz)") ax.set_ylabel(label_list[leg] + " - " + component + " part") ax.set_title(label_list[leg] + " - " + component + " part") @@ -315,13 +317,13 @@ class ImpedanceModel(): try: sum_imp = getattr(getattr(self, attr), Z_type) + zero_impedance in_ax.fill_between(sum_imp.data.index*1e-3, total_imp, - total_imp + sum_imp.data[component]*1e-9) + total_imp + sum_imp.data[component]*1e-9, edgecolor=colorblind[index%10], color=colorblind[index%10]) total_imp += sum_imp.data[component]*1e-9 except AttributeError: pass in_ax.set_xlim([0, 200]) - in_ax.set_xlabel("Frequency [kHz]") - in_ax.set_ylabel(r"$[G\Omega]$") + in_ax.set_xlabel("Frequency (kHz)") + in_ax.set_ylabel(r"$[\mathrm{G}\Omega]$") return fig