diff --git a/hp4155/ADU for double gate devices/lib/help.py b/hp4155/ADU for double gate devices/lib/help.py index 11dd42bfd4382c4554970f7b524b7b92685a43a7..6e32487381dfe7c126fd8fc59c17d9b655ce4e2f 100644 --- a/hp4155/ADU for double gate devices/lib/help.py +++ b/hp4155/ADU for double gate devices/lib/help.py @@ -164,44 +164,47 @@ def calculate_line(VTG,VBG): # replot results def replot_results(replot_dict,df,points,title): - if len(df.columns.tolist())!=0 and replot_dict['check'].value==True: # Measurement is done - fig,ax = plt.subplots(figsize=(10,6)) - - #Retrieve the columns - x_col = replot_dict['x_variable'].value - y_col = replot_dict['y_variable'].value - - #Scale and Absolute Values - - if replot_dict['x_scale'].value=='linear': - x = np.array_split(df[x_col],points) - else: - x = np.array_split(df[x_col].abs(),points) - ax.set_xscale('log') - - if replot_dict['y_scale'].value=='linear': - y = np.array_split(df[y_col],points) - else: - y = np.array_split(df[y_col].abs(),points) - ax.set_yscale('log') - - # check auto limits - if replot_dict['x_auto'].value== False and replot_dict['x_max'].value > replot_dict['x_min'].value: - ax.set_xlim([replot_dict['x_min'].value,replot_dict['x_max'].value]) - - if replot_dict['y_auto'].value== False and replot_dict['y_max'].value > replot_dict['y_min'].value: - ax.set_ylim([replot_dict['y_min'].value,replot_dict['y_max'].value]) - - # Now set the label - ax.set_xlabel(x_col) - ax.set_ylabel(y_col) - - #And Plot - for i in range(points): - ax.plot(x[i],y[i]) - - fig.suptitle(title, fontweight ="bold") - display(fig) + try: + if len(df.columns.tolist())!=0 and replot_dict['check'].value==True: # Measurement is done + fig,ax = plt.subplots(figsize=(10,6)) + + #Retrieve the columns + x_col = replot_dict['x_variable'].value + y_col = replot_dict['y_variable'].value + + #Scale and Absolute Values + + if replot_dict['x_scale'].value=='linear': + x = np.array_split(df[x_col],points) + else: + x = np.array_split(df[x_col].abs(),points) + ax.set_xscale('log') + + if replot_dict['y_scale'].value=='linear': + y = np.array_split(df[y_col],points) + else: + y = np.array_split(df[y_col].abs(),points) + ax.set_yscale('log') + + # check auto limits + if replot_dict['x_auto'].value== False and replot_dict['x_max'].value > replot_dict['x_min'].value: + ax.set_xlim([replot_dict['x_min'].value,replot_dict['x_max'].value]) + + if replot_dict['y_auto'].value== False and replot_dict['y_max'].value > replot_dict['y_min'].value: + ax.set_ylim([replot_dict['y_min'].value,replot_dict['y_max'].value]) + + # Now set the label + ax.set_xlabel(x_col) + ax.set_ylabel(y_col) + + #And Plot + for i in range(points): + ax.plot(x[i],y[i]) + + fig.suptitle(title, fontweight ="bold") + display(fig) + except: + information_box("reploting failed please try again")