# 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+'\\simFig9_r.png' fig_title = 'Primary Fig 9 reference' plot_title =['20 mV','0 mV','-20 mV','-30 mV','-40 mV','-50 mV','-60 mV'] labels = ['Original reference','CellML reference'] # Data source dfolder_original=parent+'\\originalData\\' ofilenames_p=['Fig9B_20r.csv','Fig9B_0r.csv','Fig9B_n20r.csv','Fig9B_n30r.csv','Fig9B_n40r.csv','Fig9B_n50r.csv','Fig9B_n60r.csv'] dfilenames_p=['simFig9_r_0.csv','simFig9_r_1.csv','simFig9_r_2.csv','simFig9_r_3.csv','simFig9_r_4.csv','simFig9_r_5.csv','simFig9_r_6.csv'] dfolder_sim=parent+'\\simulatedData\\' x_var_org ='x' y_var_org ='Curve1' x_var_sim = 't' y_var_sim = 'output_10/dQ' y_label= 'dQ/dt (/ms)' # Build the traces number_trace = 2 number_plot = 7 trace = [[0] * number_trace for i in range(number_plot)] for plotid, y_file in enumerate(ofilenames_p): odata_p = pd.read_csv(dfolder_original+ofilenames_p[plotid]) ox_data_p=odata_p[x_var_org].values oy_data_p=odata_p[y_var_org].values ndata_p = pd.read_csv(dfolder_sim+dfilenames_p[plotid]) nx_data_p=ndata_p[x_var_sim].values-210 ny_data_p=ndata_p[y_var_sim].values/5 trace[plotid][0]={'dataX': ox_data_p, 'dataY': oy_data_p, 'lname': labels[0], 'linestyle':lines[1], 'marker':markers[0], 'linecolor':colors[0],'y2':False} trace[plotid][1]={'dataX': nx_data_p, 'dataY': ny_data_p, 'lname': labels[1], 'linestyle':lines[0], 'marker':None, 'linecolor':colors[1],'y2':False} # Build the plots # maxH=8.75 inches, width 2.63-7.5 rows,cols = 4,2 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.9 # 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.55 # 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*3.5, rows*1.75 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} plots=[] for id in range(7): colid = id%2 rowid = id//2 if id == 0: lgdshow = True bbox_to_anchor = (1.2,1.35) else: lgdshow = False bbox_to_anchor = None if id==5 or id==6: x_label='t (ms)' else: x_label='' if id==0: iplot={'rowid':rowid, 'colid':colid, 'xlabel': x_label, 'ylabel':y_label, 'twiny':False, 'ylabel2':y_label,'labelcolor':colors[1], 'lgdshow': lgdshow, 'lgdloc':'center', 'bbox_to_anchor':bbox_to_anchor,'lgdncol': 4, '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, 'ylabel':y_label, 'twiny':False, 'ylabel2':y_label,'labelcolor':colors[1], 'lgdshow': lgdshow, 'lgdloc':'center', 'bbox_to_anchor':bbox_to_anchor,'lgdncol': 4, '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(7) subfigs={ids: plots for ids, plots in zip(ids, plots)} fig,axs=plotExp.plotExp(figs,subfigs,figfiles)