# importing modules import sys as sys import os import pandas as pd import matplotlib.pyplot as plt # Getting the name of the directory where this file is present. current = os.path.dirname(os.path.realpath(__file__)) # src # Getting the parent directory name where the current directory is present. parent = os.path.dirname(current) # Simulation # Getting the grandparent directory name gparent = os.path.dirname(parent) # RecruitmentSynchronization_SMCs # The path where the plotExp.py is saved mpath = gparent + '\\cellLib\\Scripts' # appending a path sys.path.append(mpath) import plotExp # The properties of traces colors=plt.rcParams['axes.prop_cycle'].by_key()['color'] lines = ['-','--','-.',':'] markers = ['.',',','o','+','x','d'] # Figure file name and titles figfiles=parent+'\\simFig6.png' fig_title = 'Steady states from the settings in Primary Fig 6' plot_title =['Voltage dependency of Q','Transfer function','Voltage dependency of P',] labels = ['$Q$-908 reference','$Q_{ss}$-908 reference','$Q$-908 perchlorate','$Q_{ss}$-908 perchlorate','$Q$-911 perchlorate','$Q_{ss}$-911 perchlorate', '$P$-908 reference','$P_{ss}$-908 reference','$P$-908 perchlorate','$P_{ss}$-908 perchlorate','$P$-911 perchlorate','$P_{ss}$-911 perchlorate', '$P$-908 reference','$P_{ss}$-908 reference','$P$-908 perchlorate','$P_{ss}$-908 perchlorate','$P$-911 perchlorate','$P_{ss}$-911 perchlorate', ] # Data source dfolders =['simFig6_r908.csv','simFig6_p908.csv','simFig6_p911.csv'] dfilename_sim=parent+'\\simulatedData\\simFig6_r908.csv' x_var_sim = ['clamp_para/V_actTest','output_10/Q','clamp_para/V_actTest'] y_vars_sim = ['output_10/Q','output_10/P_o','output_10/P_o'] ss_vars_sim = ['output_10/Q_ss','output_10/P_ss','output_10/P_ss'] x_label=['Voltage (mV)','Charge ($nC/\mu F$)','Voltage (mV)'] y_label=['Charge ($nC/\mu F$)','Ca Release (normalized)','Ca Release (normalized)'] dfilename_sim=parent+'\\simulatedData\\'+dfolders[0] data_r = pd.read_csv(dfilename_sim) dfilename_sim=parent+'\\simulatedData\\'+dfolders[1] data_p908 = pd.read_csv(dfilename_sim) dfilename_sim=parent+'\\simulatedData\\'+dfolders[2] data_p911 = pd.read_csv(dfilename_sim) # Build the traces number_trace = 6 number_plot = len(y_vars_sim) trace = [[0] * number_trace for i in range(number_plot)] trace_right = [0]* number_trace for plotid, y_var_sim in enumerate(y_vars_sim): if y_var_sim=='output_10/Q': Qmax=32 x_data_r=data_r[x_var_sim[plotid]].values y_data_r=data_r[y_var_sim].values*Qmax ss_data_r=data_r[ss_vars_sim[plotid]].values*Qmax Qmax=32.8 x_data_p908=data_p908[x_var_sim[plotid]].values y_data_p908=data_p908[y_var_sim].values*Qmax ss_data_p908=data_p908[ss_vars_sim[plotid]].values*Qmax x_data_p911=data_p911[x_var_sim[plotid]].values y_data_p911=data_p911[y_var_sim].values*Qmax ss_data_p911=data_p911[ss_vars_sim[plotid]].values*Qmax else: y_data_r=data_r[y_var_sim].values/0.338011898368225 ss_data_r=data_r[ss_vars_sim[plotid]].values/0.338011898368225 x_data_r=data_r[x_var_sim[plotid]].values y_data_p908=data_p908[y_var_sim].values/0.927352133862348 ss_data_p908=data_p908[ss_vars_sim[plotid]].values/0.927352133862348 x_data_p908=data_p908[x_var_sim[plotid]].values y_data_p911=data_p911[y_var_sim].values/0.894396102653842 ss_data_p911=data_p911[ss_vars_sim[plotid]].values/0.894396102653842 x_data_p911=data_p911[x_var_sim[plotid]].values if plotid==1: Qmax=32 x_data_r=x_data_r*Qmax Qmax=32.8 x_data_p908=x_data_p908*Qmax x_data_p911=x_data_p911*Qmax trace[plotid][0]={'dataX': x_data_r, 'dataY': y_data_r, 'lname': labels[plotid*6+0], 'linestyle':lines[0], 'marker':None, 'linecolor':colors[0],'y2':False} trace[plotid][1]={'dataX': x_data_r, 'dataY': ss_data_r, 'lname': labels[plotid*6+1], 'linestyle':lines[1], 'marker':markers[4], 'linecolor':colors[0],'y2':False} trace[plotid][2]={'dataX': x_data_p908, 'dataY': y_data_p908, 'lname': labels[plotid*6+2], 'linestyle':lines[0], 'marker':None, 'linecolor':colors[1],'y2':False} trace[plotid][3]={'dataX': x_data_p908, 'dataY': ss_data_p908, 'lname': labels[plotid*6+3], 'linestyle':lines[1], 'marker':markers[4], 'linecolor':colors[1],'y2':False} trace[plotid][4]={'dataX': x_data_p911, 'dataY': y_data_p911, 'lname': labels[plotid*6+4], 'linestyle':lines[0], 'marker':None, 'linecolor':colors[2],'y2':False} trace[plotid][5]={'dataX': x_data_p911, 'dataY': ss_data_p911, 'lname': labels[plotid*6+5], 'linestyle':lines[1], 'marker':markers[4], 'linecolor':colors[2],'y2':False} # Build the plots # maxH=8.75 inches, width 2.63-7.5 rows,cols = 1,3 left = 0.125 # the left side of the subplots of the figure,0.125 right = 0.9 # the right side of the subplots of the figure,0.9 bottom = 0.1 # the bottom of the subplots of the figure, 0.1 top = 0.75 # the top of the subplots of the figure 0.9 wspace = 0.5 # the amount of width reserved for space between subplots, # expressed as a fraction of the average axis width, 0.2 hspace = 0.1 # the amount of height reserved for space between subplots, # expressed as a fraction of the average axis height, 0.2 lgdfont, labelfont =10, 10 width, height= cols*2.5, rows*5 figs ={ 'width':width, 'height': height, 'rows': rows, 'cols': cols,'left':left,'bottom':bottom,'right':right,'top':top,'wspace': wspace,'hspace': hspace,'fig_title':fig_title,'title_y':1.0} plots=[] for id in range(3): colid = id%cols rowid = id//cols if id == 0: lgdshow = True bbox_to_anchor = (2,1.2) else: lgdshow = False bbox_to_anchor = (0.5,1.4) if id==0: iplot={'rowid':rowid, 'colid':colid, 'xlabel': x_label[id], 'ylabel':y_label[id], 'twiny':False, 'ylabel2':y_label[id+1],'labelcolor':colors[1], 'lgdshow': lgdshow, 'lgdloc':'center', 'bbox_to_anchor':bbox_to_anchor,'lgdncol': 3, 'lgdfont':lgdfont, 'labelfont': labelfont, 'setxlim': False, 'xmin':0, 'xmax': 1, 'setylim': False,'ymin':0, 'ymax':1, 'grid': True, 'gridaxis': 'both', 'plot_title': plot_title[id], 'traces':trace[id] } else: iplot={'rowid':rowid, 'colid':colid, 'xlabel': x_label[id], 'ylabel':y_label[id], 'twiny':False, 'ylabel2':y_label[id],'labelcolor':colors[1], 'lgdshow': lgdshow, 'lgdloc':'center', 'bbox_to_anchor':bbox_to_anchor,'lgdncol': 1, 'lgdfont':lgdfont, 'labelfont': labelfont, 'setxlim': False, 'xmin':0, 'xmax': 1, 'setylim': False,'ymin':0, 'ymax':1, 'grid': True, 'gridaxis': 'both', 'plot_title': plot_title[id], 'traces':trace[id] } plots.append(iplot) ids = range(len(y_vars_sim)) subfigs={ids: plots for ids, plots in zip(ids, plots)} fig,axs=plotExp.plotExp(figs,subfigs,figfiles)