diff --git a/chem_spectra/lib/composer/ni.py b/chem_spectra/lib/composer/ni.py index 105fa6e..7b66d27 100644 --- a/chem_spectra/lib/composer/ni.py +++ b/chem_spectra/lib/composer/ni.py @@ -491,6 +491,9 @@ def tf_img(self): plt.ylabel("Y ({})".format(self.core.label['y']), fontsize=18) plt.locator_params(nbins=self.__plt_nbins()) plt.grid(False) + + self.__generate_info_box(plt) + # Save tf_img = tempfile.NamedTemporaryFile(suffix='.png') plt.savefig(tf_img, format='png') @@ -499,6 +502,25 @@ def tf_img(self): plt.cla() return tf_img + + def __generate_info_box(self, plotlib): + if not self.core.is_sec: + return + core_dic = self.core.dic + sec_data_key = ['MN', 'MW', 'MP', 'D'] + result = [] + for key in sec_data_key: + dic_value = core_dic.get(key, []) + key_str = f"{key}={dic_value[0]}" if len(dic_value) > 0 else None + if key_str is not None: + result.append(key_str) + + info_str = '\n'.join(result) + props = dict(boxstyle='round', facecolor='wheat', alpha=0.5) + ax = plotlib.gca() + ax.text(0.05, 0.95, info_str, fontsize=14, verticalalignment='top', bbox=props, transform=ax.transAxes) + + def __prepare_metadata_info_for_csv(self, csv_writer: csv.DictWriter): csv_writer.writerow({ 'Anodic E(V)': 'Measurement type',