def main_assemble(): plt.close("all") plt.rcParams.update({'font.size': 28}) measurements = meas.measurements() for measurement in measurements: f_pull, z_pull, f_release, z_release, title = hmf.read_analyze_compare( measurement, p) wlc, _ = func.WLC(f_pull, L_bp=p['L_bp'], P_nm=p['P_nm'], S_pN=p['S_pN']) plt.scatter(1000 * z_pull, f_pull, label=title, s=10, zorder=25) # plt.scatter(1000 * z_release, f_release, color='lightgrey', s=10, zorder=15, facecolors='none') plt.plot(wlc, f_pull, '--', color="black", label="WLC") plt.ylabel('F (pN)') plt.xlabel('z (nm)') plt.ylim(-1, 52) plt.xlim(0, 1350) # plt.yscale('log') # plt.ylim(10 ** -1, 10 ** 2) plt.legend(loc=2, frameon=False) plt.tick_params(direction='in', axis="both", bottom="on", top="on", left="on", right="on") # placement of figure mngr = plt.get_current_fig_manager() mngr.window.setGeometry(0, 56, 3840, 2004) # laptop # mngr.window.setGeometry(0, -1024, 1920, 984) # work PC # HMfB - reference # f_pull, z_pull, f_release, z_release, title = hmf.read_analyze_compare(['171201', '012', ' 5', 'HMfB'], p) # f_pull, z_pull, f_release, z_release, title = hmf.read_analyze_compare(['171201', '007', '18', 'HMfB'], p) # plt.scatter(1000 * z_pull, f_pull, label=title, s=20, zorder=100, color='black') plt.title(title[-4:] + " assembly") plt.show() return
def main_fit_no_constant(): plt.close("all") measurements = meas.measurements() f_pull, z_pull, f_release, z_release, title = hmf.read_analyze( measurements, p) wlc, _ = func.WLC(f_pull, L_bp=p['L_bp'], P_nm=p['P_nm'], S_pN=p['S_pN']) Fmax_pN = np.max(f_pull) f = np.logspace(np.log10(0.02), np.log10(int(Fmax_pN)), 1000) n_prot = (p['L_bp'] // p['L1_bp']) # plot the states Z, Zi, Gi = hmf.hmf_WLC(f, pars=p) barrier = hmf.barrier(p) plt.rcParams.update({'font.size': 14}) # select high-force data select_f = f_pull[np.where((f_pull > 5) & (f_pull < 50))] select_z = z_pull[np.where((f_pull > 5) & (f_pull < 50))] select_z *= 1000 if p['two_transitions']: if p['fit_G1']: # fit the Boltzmann distribution to find 'G2' and 'constant' popt, pcov = curve_fit( lambda f, G1, G2: hmf.hmf_boltzmann_fit(f, p, G1, G2, 0), select_f, select_z, p0=[p['G1_kT'], p['G2_kT']], bounds=(0.01, [10, 100])) print("G1 = " + str(popt[0]) + " kT") print("G2 = " + str(popt[1]) + " kT") print("constant = 0") p['G1_kT'] = popt[0] p['G2_kT'] = popt[1] p['constant'] = 0 else: # fit the Boltzmann distribution to find 'G2' and 'constant' popt, pcov = curve_fit( lambda f, G2: hmf.hmf_boltzmann_fit(f, p, p['G1_kT'], G2, 0), select_f, select_z, p0=p['G2_kT'], bounds=(0.01, 100)) print("G1 = " + str(p['G1_kT']) + " kT") print("G2 = " + str(popt[0]) + " kT") print("constant = 0") p['G2_kT'] = popt[0] p['constant'] = 0 # plot the Boltzmann distribution Z = hmf.hmf_boltzmann_fit(f, p, G1=p['G1_kT'], G2=p['G2_kT'], constant=p['constant']) plt.plot(Z, f, color='k', linewidth=3, zorder=120, label="Stat.Mech.Model fit") else: # fit the Boltzmann distribution to find 'G2', 'G3' and 'constant' if p['fit_G1']: print("Starting fit procedure...") popt, pcov = curve_fit( lambda f, G1, G2, G3: hmf.hmf_boltzmann_fit_three( f, p, G1, G2, G3, 0), select_f, select_z, p0=[p['G1_kT'], p['G2_kT'], p['G3_kT']], bounds=(0.01, [10, 100, 100])) print("Done!") print("G1 = " + str(popt[0]) + " kT") print("G2 = " + str(popt[1]) + " kT") print("G3 = " + str(popt[2]) + " kT") print("constant = 0") p['G1_kT'] = popt[0] p['G2_kT'] = popt[1] p['G3_kT'] = popt[2] p['constant'] = 0 else: popt, pcov = curve_fit( lambda f, G2, G3: hmf.hmf_boltzmann_fit_three( f, p, p['G1_kT'], G2, G3, 0), select_f, select_z, p0=[p['G2_kT'], p['G3_kT']], bounds=(0.01, [100, 100])) print("G1 = " + str(p['G1_kT']) + " kT") print("G2 = " + str(popt[0]) + " kT") print("G3 = " + str(popt[1]) + " kT") print("constant = 0") p['G2_kT'] = popt[0] p['G3_kT'] = popt[1] p['constant'] = 0 # plot the Boltzmann distribution Z = hmf.hmf_boltzmann_fit_three(f, p, G1=p['G1_kT'], G2=p['G2_kT'], G3=p['G3_kT'], constant=p['constant']) plt.plot(Z, f, color='k', linewidth=3, zorder=120, label="Stat.Mech.Model fit") # plot the grid colors = iter(cm.rainbow(np.linspace(0, 1, len(Zi)))) for n, z in enumerate(Zi): plt.plot(z, f, color=next(colors), linewidth=2, zorder=int(-n)) plt.plot(Zi[0], f, '--', color='lightgrey', linewidth=4, zorder=1000, label='state 0') plt.plot(Zi[barrier], f, '--', color='grey', linewidth=4, zorder=1000, label='state 1') plt.plot(wlc, f_pull, '--', color="black", linewidth=4, zorder=10000, label='state 2') if p['two_transitions'] == False: plt.plot(Zi[barrier + n_prot - p['dimer_beads']], f, '--', color='dimgrey', linewidth=4, zorder=1000, label='state 1.5') # plot the data if title[-4:] == "HMfA": pull_color = 'navy' release_color = 'lightblue' else: pull_color = 'darkgreen' release_color = 'lightgrey' plt.ylabel('F (pN)') plt.xlabel('z (nm)') plt.ylim(-0.5, 5) plt.xlim(0, 1000) plt.ylim(-1, 52) plt.xlim(0, 1350) plt.yscale('log') plt.ylim(10**-1, 10**2) plt.scatter(1000 * z_pull, f_pull, color=pull_color, label="Pull", s=200, zorder=25, facecolors='none') plt.scatter(1000 * z_release, f_release, color=release_color, s=200, zorder=15, label='Release', facecolors='none') plt.legend(loc=2, frameon=False) plt.tick_params(direction='in', axis="both", bottom="on", top="on", left="on", right="on") plt.title(title[-4:]) # placement of figure mngr = plt.get_current_fig_manager() mngr.window.setGeometry(0, 56, 3840, 2004) # laptop mngr.window.setGeometry(0, -1024, 1920, 984) # work PC plt.show() return
def main(): plt.close("all") measurements = meas.measurements() f_pull, z_pull, f_release, z_release, title = hmf.read_analyze( measurements, p) wlc, _ = func.WLC(f_pull, L_bp=p['L_bp'], P_nm=p['P_nm'], S_pN=p['S_pN']) Fmax_pN = np.max(f_pull) f = np.logspace(np.log10(0.02), np.log10(int(Fmax_pN)), 1000) n_prot = (p['L_bp'] // p['L1_bp']) # plot the states Z, Zi, Gi = hmf.hmf_WLC(f, pars=p) barrier = hmf.barrier(p) skip = 1 Gi = Gi[::skip] Zi = Zi[::skip] plt.rcParams.update({'font.size': 14}) ''' Force Extension plot ''' # plot the grid colors = iter(cm.rainbow(np.linspace(0, 1, len(Zi)))) for n, z in enumerate(Zi): plt.plot(z, f, color=next(colors), linewidth=2, zorder=int(-n)) plt.plot(Zi[0], f, '--', color='lightgrey', linewidth=2, zorder=1000, label='state 0') plt.plot(Zi[barrier], f, '--', color='grey', linewidth=2, zorder=1000, label='state 1') # if p['two_transitions'] == False: # plt.plot(Zi[barrier + n_prot - p['dimer_beads']], f, '--', color='dimgrey', linewidth=4, zorder=1000, # label='state 1.5') plt.plot(wlc, f_pull, '--', color="black", linewidth=2, zorder=10000, label='state 2') # plt.plot(Zi[121-45], f, '--', color='red', linewidth=2, zorder=1000, label = "Kulic") # Kulic Requirement # plot the Boltzmann distribution # Z_b = hmf.hmf_boltzmann_fit_three_fix(f, p, p['G1_kT'], p['G2_kT'], p['constant'], p['constant_wlc']) # plt.plot(Z_b, f, color='k', linewidth=3, zorder=120, label="Stat.Mech.Model fit") # plot the data if title[-4:] == "HMfA": pull_color = 'navy' release_color = 'lightblue' else: pull_color = 'darkgreen' release_color = 'lightgrey' plt.ylabel('F (pN)') plt.xlabel('z (nm)') plt.tick_params(direction='in', top=True, right=True) plt.ylim(-0.5, 5) plt.xlim(0, 1000) plt.ylim(-1, 52) plt.xlim(0, 1350) plt.yscale('log') plt.ylim(10**-1, 10**2) plt.scatter(1000 * z_pull, f_pull, color=pull_color, label="Pull", s=100, zorder=25, facecolors='none') plt.scatter(1000 * z_release, f_release, color=release_color, s=100, zorder=15, label='Release', facecolors='none') # plt.plot(wlc, f_pull, '--', color="black", label="WLC", zorder=10000) plt.legend(loc=2, frameon=False) plt.tick_params(direction='in', axis="both", bottom="on", top="on", left="on", right="on") # plt.title(title[-4:] + ', G2 = ' + str(p['G2_kT']) + ' kT, G3 = ' + str(p['G3_kT']) + ' kT') # plt.title(title[-4:]) save = p['save'] # placement of figure mngr = plt.get_current_fig_manager() mngr.window.setGeometry(0, 56, 3840, 2004) # laptop # mngr.window.setGeometry(0, -1024, 1920, 984) # work PC # if save: # # save figure # plt.rcParams.update({'font.size': 14}) # plt.savefig('C:\\Brouwer\\HMf analysis\\Fits\\' + str(title) + '__' + time.strftime("%H%M%S") + ".png", dpi=300) # # save parameters # with open('C:\\Brouwer\\HMf analysis\\Fits\\' + str(title) + '__' + time.strftime("%H%M%S") + '.json', # 'w') as ff: # ff.write(json.dumps(p)) plt.show() # plt.close() ''' Energy Plot ''' sequence = False if sequence: for F_ref in range(0, 151): F_ref /= 10 plt.title(' F = ' + str(F_ref) + ' pN', ha=u'left') colors = iter(cm.rainbow(np.linspace(0, 1, len(Zi)))) for g, z in zip(Gi, Zi): g_tot = g - F_ref * z / kT plt.plot(z, g_tot, color=next(colors), linewidth=2) # ax[1].plot(z_ref, w_ref, color = 'k', linewidth = 2) plt.ylim(-3000, 3000) plt.xlim(0, 1350) plt.ylabel('G (kT)') plt.xlabel('z (nm)') plt.tick_params(direction='in', top=True, right=True) plt.savefig("C:\\Users\\brouw\\Desktop\\Figs\\Free Energy @ " + str(F_ref) + " pN.png") plt.tight_layout() plt.close() # plt.show() else: F_ref = 30 plt.title(' F = ' + str(F_ref) + ' pN', ha=u'left') colors = iter(cm.rainbow(np.linspace(0, 1, len(Zi)))) for g, z in zip(Gi, Zi): g_tot = g - F_ref * z / kT plt.plot(z, g_tot, color=next(colors), linewidth=2) plt.ylim(-7000, -6000) plt.xlim(0, 1350) plt.ylabel('G (kT)') plt.xlabel('z (nm)') plt.tick_params(direction='in', top=True, right=True) # plt.tight_layout() # plt.show() plt.close() ''' # plotting the difference between states diff_FJC = [] diff_WLC = [] diff_tot = [] for z_fjc, z_wlc, z_tot in zip(Z_FJC, Z_WLC, Zi): diff_FJC.append(max(z_fjc)) diff_WLC.append(max(z_wlc)) diff_tot.append(max(z_tot)) diff_FJC = [j - i for i, j in zip(diff_FJC[:-1], diff_FJC[1:])] diff_WLC = [j - i for i, j in zip(diff_WLC[:-1], diff_WLC[1:])] diff_tot = [j - i for i, j in zip(diff_tot[:-1], diff_tot[1:])] x = np.arange(len(diff_WLC)) plt.scatter(x, diff_FJC, label = "FJC") plt.scatter(x, diff_WLC, label = "WLC") plt.scatter(x, diff_tot, marker='x', s = 115, label = "Total") plt.ylabel("Max distance between states (nm)") plt.xlabel("States") plt.legend() plt.show() ''' return
def main_compare(): plt.close("all") plt.rcParams.update({'font.size': 45}) plt.rc('axes', linewidth=4) plt.figure(figsize=(17.5, 22)) plt.rcParams['xtick.major.size'] = 20 plt.rcParams['xtick.major.width'] = 4 plt.rcParams['xtick.minor.size'] = 10 plt.rcParams['xtick.minor.width'] = 2 plt.rcParams['ytick.major.size'] = 20 plt.rcParams['ytick.major.width'] = 4 plt.rcParams['ytick.minor.size'] = 10 plt.rcParams['ytick.minor.width'] = 2 plt.tick_params(direction='in', top=True, right=True) p = default_pars() measurements = meas.measurements() for n, measurement in enumerate(measurements): if p['load_pars'] == True: par_dir = "C:\\Brouwer\\HMf analysis\\Fits\\" par_file = str(measurement[0]) + "_" + str( measurement[1]) + "_" + str(measurement[2]) + "_" + str( measurement[3]) + ".json" # open parameters with open(par_dir + par_file, 'r') as read_file: loaded_parameters = json.loads(read_file.read()) p = loaded_parameters print(measurement) print(p) f_pull, z_pull, f_release, z_release, title = hmf.read_analyze_compare( measurement, p) wlc, _ = func.WLC(f_pull, L_bp=p['L_bp'], P_nm=p['P_nm'], S_pN=p['S_pN']) if title[-4:] == "HMfA": pull_color = 'red' release_color = 'grey' else: pull_color = 'forestgreen' release_color = 'grey' plt.scatter(1000 * z_pull, f_pull, color=pull_color, label=title[-4:], s=500, linewidth=2, zorder=25, alpha=0.7, facecolors='none') plt.scatter(1000 * z_release, f_release, color=release_color, s=500, linewidth=2, zorder=15, alpha=0.7, facecolors='none') Fmax_pN = np.max(f_pull) f = np.logspace(np.log10(0.02), np.log10(int(Fmax_pN)), 1000) # plot the Boltzmann distribution Z_b = hmf.hmf_boltzmann_fit(f, p, p['G1_kT'], p['G2_kT'], p['constant']) # if n == 0: # plt.plot(Z_b, f, color='black', linewidth=6, zorder=120, label="Stat.Mech.Model fit") # else: # plt.plot(Z_b, f, color='black', linewidth=6, zorder=120) plt.plot(Z_b, f, color='black', linewidth=10, zorder=10000) # plot the states Z, Zi, Gi = hmf.hmf_WLC(f, pars=p) barrier = hmf.barrier(p) # plot the grid # colors = iter(cm.rainbow(np.linspace(0, 1, len(Zi)))) # for n, z in enumerate(Zi): # plt.plot(z, f, color=next(colors), linewidth=2, zorder=int(-n)) # if p['two_transitions'] == False: # plt.plot(Zi[barrier + n_prot - p['dimer_beads']], f, '--', color='dimgrey', linewidth=4, zorder=1000, # label='state 1.5') # plt.plot(Zi[0], f, '--', color='lightgrey', linewidth=5, zorder=1000, label='state 0') # plt.plot(Zi[barrier], f, '--', color='grey', linewidth=5, zorder=1000, label='state 1') plt.plot(wlc, f_pull, '--', color="black", linewidth=5, zorder=10000, label='WLC') plt.ylabel('F (pN)') plt.xlabel('z (nm)') plt.ylim(-1, 52) plt.xlim(0, 1500) plt.yscale('log') plt.ylim(10**-1, 10**2) plt.xticks(range(0, 1501, 500)) plt.legend(loc=2, frameon=False) plt.tick_params(direction='in', axis="both", bottom="on", top="on", left="on", right="on") # placement of figure # mngr = plt.get_current_fig_manager() # mngr.window.setGeometry(0, 56, 3840, 2004) # laptop # mngr.window.setGeometry(0, -1024, 1920, 984) # work PC # plt.title("HMfA / HMfB comparison") plt.savefig('C:\\Brouwer\\HMf analysis\\Figure 2A - HMfA-HMfB comparison', dpi=600) plt.savefig( 'C:\\Brouwer\\HMf analysis\\Figure 2A - HMfA-HMfB comparison.pdf') plt.show() return
def main_fit_three(): plt.close("all") measurements = meas.measurements() f_pull, z_pull, f_release, z_release, title = hmf.read_analyze( measurements, p) wlc, _ = func.WLC(f_pull, L_bp=p['L_bp'], P_nm=p['P_nm'], S_pN=p['S_pN']) Fmax_pN = np.max(f_pull) f = np.logspace(np.log10(0.02), np.log10(int(Fmax_pN)), 1000) n_prot = (p['L_bp'] // p['L1_bp']) # plot the states Z, Zi, Gi = hmf.hmf_WLC(f, pars=p) barrier = hmf.barrier(p) plt.rcParams.update({'font.size': 28}) # select high-force data lower_bound = 0.5 higher_bound = 50 select_f = f_pull[np.where((f_pull > lower_bound) & (f_pull < higher_bound))] select_z = z_pull[np.where((f_pull > lower_bound) & (f_pull < higher_bound))] select_z *= 1000 if p['two_transitions']: if p['fit_G1']: if p['fit_G1_only']: # fit the Boltzmann distribution to find 'G2' and 'constant' popt, pcov = curve_fit(lambda f, G1: hmf.hmf_boltzmann_fit( f, p, G1, p['G2_kT'], p['constant']), select_f, select_z, p0=p['G1_kT'], bounds=(0.01, 10)) p['G1_kT'] = popt[0] p['fitted_G1_var'] = pcov[0][0] print("G1 = " + str(round(p['G1_kT'], 2)) + " +/- " + str(round(p['fitted_G1_var'], 2)) + " kT") print("G2 = " + str(p['G2_kT']) + " kT") print("constant = " + str(p['constant'])) else: # fit the Boltzmann distribution to find 'G2' and 'constant' popt, pcov = curve_fit( lambda f, G1, G2, constant: hmf.hmf_boltzmann_fit( f, p, G1, G2, constant), select_f, select_z, p0=[p['G1_kT'], p['G2_kT'], p['constant']], bounds=(0.01, [10, 100, 1])) p['G1_kT'] = popt[0] p['G2_kT'] = popt[1] p['constant'] = popt[2] p['fitted_G1_var'] = pcov[0][0] p['fitted_G2_var'] = pcov[1][1] p['fitted_constant_var'] = pcov[2][2] print("G1 = " + str(round(p['G1_kT'], 2)) + " +/- " + str(round(p['fitted_G1_var'], 2)) + " kT") print("G2 = " + str(round(p['G2_kT'], 2)) + " +/- " + str(round(p['fitted_G2_var'], 2)) + " kT") print("constant = " + str(round(p['constant'], 2)) + " +/- " + str(round(p['fitted_constant_var'], 2))) else: # fit the Boltzmann distribution to find 'G2' and 'constant' popt, pcov = curve_fit( lambda f, G2, constant: hmf.hmf_boltzmann_fit( f, p, p['G1_kT'], G2, constant), select_f, select_z, p0=[p['G2_kT'], p['constant']], bounds=(0.01, [100, 1])) p['G2_kT'] = popt[0] p['constant'] = popt[1] p['fitted_G2_var'] = pcov[0][0] p['fitted_constant_var'] = pcov[1][1] print("G1 = " + str(p['G1_kT']) + " kT") print("G2 = " + str(round(p['G2_kT'], 2)) + " +/- " + str(round(p['fitted_G2_var'], 2)) + " kT") print("constant = " + str(round(p['constant'], 2)) + " +/- " + str(round(p['fitted_constant_var'], 2))) # plot the Boltzmann distribution Z = hmf.hmf_boltzmann_fit(f, p, G1=p['G1_kT'], G2=p['G2_kT'], constant=p['constant']) plt.plot(Z, f, color='k', linewidth=3, zorder=120, label="Stat.Mech.Model fit") else: # fit the Boltzmann distribution to find 'G2', 'G3' and 'constant' if p['fit_G1']: print("Starting fit procedure...") t1 = time.time() popt, pcov = curve_fit( lambda f, G1, G2, constant, constant_wlc: hmf.hmf_boltzmann_fit_three_fix( f, p, G1, G2, constant, constant_wlc), select_f, select_z, p0=[p['G1_kT'], p['G2_kT'], p['constant'], p['constant_wlc']], bounds=(0.01, [10, 100, 1, 1])) t2 = time.time() t_tot = t2 - t1 print("Done! Elapsed time: " + str(round(t_tot, 2)) + " seconds") p['G1_kT'] = popt[0] p['G2_kT'] = popt[1] p['constant'] = popt[2] p['constant_wlc'] = popt[3] p['fitted_G1_var'] = pcov[0][0] p['fitted_G2_var'] = pcov[1][1] p['fitted_constant_var'] = pcov[2][2] p['fitted_constant_wlc_var'] = pcov[3][3] print("G1 = " + str(round(p['G1_kT'], 2)) + " +/- " + str(round(p['fitted_G1_var'], 2)) + " kT") print("G2 = " + str(round(p['G2_kT'], 2)) + " +/- " + str(round(p['fitted_G2_var'], 2)) + " kT") print("constant = " + str(round(p['constant'], 2)) + " +/- " + str(round(p['fitted_constant_var'], 2))) print("constant_wlc = " + str(round(p['constant_wlc'], 2)) + " +/- " + str(round(p['fitted_constant_wlc_var'], 2))) else: # ''' print("Starting fit procedure...") t1 = time.time() popt, pcov = curve_fit( lambda f, G2, constant_wlc: hmf.hmf_boltzmann_fit_three_fix( f, p, p['G1_kT'], G2, p['constant'], constant_wlc), select_f, select_z, p0=[p['G2_kT'], p['constant_wlc']], bounds=(0.001, [100, 1])) t2 = time.time() t_tot = t2 - t1 print("Done! Elapsed time: " + str(round(t_tot, 2)) + " seconds") p['G2_kT'] = popt[0] p['constant_wlc'] = popt[1] p['fitted_G2_var'] = pcov[0][0] p['fitted_constant_wlc_var'] = pcov[1][1] print("G1 = " + str(p['G1_kT']) + " kT") print("G2 = " + str(round(p['G2_kT'], 2)) + " +/- " + str(round(p['fitted_G2_var'], 2)) + " kT") print("constant = " + str(round(p['constant'], 2))) print("constant_wlc = " + str(round(p['constant_wlc'], 2)) + " +/- " + str(round(p['fitted_constant_wlc_var'], 2))) ''' print("Starting fit procedure...") t1 = time.time() popt, pcov = curve_fit( lambda f, G2 : hmf.hmf_boltzmann_fit_three_fix(f, p, p['G1_kT'], G2, p['constant'], p['constant_wlc']), select_f, select_z, p0=p['G2_kT'], bounds=(0.001, 100)) t2 = time.time() t_tot = t2 - t1 print("Done! Elapsed time: " + str(round(t_tot,2)) + " seconds") p['G2_kT'] = popt[0] p['fitted_G2_var'] = pcov[0][0] print("G1 = " + str(p['G1_kT']) + " kT") print("G2 = " + str(round(p['G2_kT'], 2)) + " +/- " + str(round(p['fitted_G2_var'], 2)) + " kT") print("constant = " + str(round(p['constant'], 2))) print("constant_wlc = " + str(round(p['constant_wlc'], 2))) ''' # plot the Boltzmann distribution Z = hmf.hmf_boltzmann_fit_three_fix(f, p, G1=p['G1_kT'], G2=p['G2_kT'], constant_fjc=p['constant'], constant_wlc=p['constant_wlc']) plt.plot(Z, f, color='k', linewidth=3, zorder=120, label="Stat.Mech.Model fit") # plot the grid colors = iter(cm.rainbow(np.linspace(0, 1, len(Zi)))) for n, z in enumerate(Zi): plt.plot(z, f, color=next(colors), linewidth=2, zorder=int(-n)) plt.plot(Zi[0], f, '--', color='lightgrey', linewidth=4, zorder=1000, label='state 0') plt.plot(Zi[barrier], f, '--', color='grey', linewidth=4, zorder=1000, label='state 1') plt.plot(wlc, f_pull, '--', color="black", linewidth=4, zorder=10000, label='state 2') if p['two_transitions'] == False: plt.plot(Zi[barrier + n_prot - p['dimer_beads']], f, '--', color='dimgrey', linewidth=4, zorder=1000, label='state 1.5') # plot the data if title[-4:] == "HMfA": pull_color = 'navy' release_color = 'lightblue' else: pull_color = 'darkgreen' release_color = 'lightgrey' plt.ylabel('F (pN)') plt.xlabel('z (nm)') plt.ylim(-0.5, 5) plt.xlim(0, 1000) plt.ylim(-1, 52) plt.xlim(0, 1350) plt.yscale('log') plt.ylim(10**-1, 10**2) plt.scatter(1000 * z_pull, f_pull, color=pull_color, label="Pull", s=200, zorder=25, facecolors='none') plt.scatter(1000 * z_release, f_release, color=release_color, s=200, zorder=15, label='Release', facecolors='none') plt.legend(loc=2, frameon=False) plt.tick_params(direction='in', axis="both", bottom="on", top="on", left="on", right="on") plt.title(title[-4:]) save = p['save'] if save: # save figure plt.savefig('C:\\Brouwer\\HMf analysis\\Fits\\' + str(title) + ".png") # save parameters with open('C:\\Brouwer\\HMf analysis\\Fits\\' + str(title) + '.json', 'w') as ff: ff.write(json.dumps(p)) # placement of figure # mngr = plt.get_current_fig_manager() # mngr.window.setGeometry(0, 56, 3840, 2004) # laptop # mngr.window.setGeometry(0, -1024, 1920, 984) # work PC plt.show() return