# importing modules from asyncio import constants import sys as sys import os import numpy 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) # SinglePASMC # 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+'\\simFig4_ci.png' fig_title = 'Response of an isolated SMC provoked by 80 mM KCl' plot_title =['$Ca^{2+}$ concentration in the cytosol'] labels = ['$c_{i0}=0.07997$,$s_{i0}=0.347$,$v_{i0}=-25$','$c_{i0}=0.07997$,$s_{i0}=0.347$,$v_{i0}=-45$','$c_{i0}=0.1$,$s_{i0}=1.12$,$v_{i0}=-30$','Original'] # Data source dfile_original=parent+'\\originalData\\Fig4.csv' dfolder_sim=parent+'\\simulatedData\\' x_var_org ='x' y_var_org ='Curve1' x_var_sim = 't' y_vars_sim = [['output/c_i']] x_label='t(s)' y_label=['$c_{i}(\mu M)$'] # Build the traces number_trace = 3 number_plot = len(y_vars_sim) trace = [[0] * number_trace for i in range(number_plot)] data = pd.read_csv(dfile_original) x_data=data[x_var_org].values y_data=data[y_var_org].values trace_org={'dataX': x_data, 'dataY': y_data, 'lname': labels[number_trace], 'linestyle':lines[1], 'marker':None, 'linecolor':colors[number_trace],'y2':False} for plotid, y_var_sim in enumerate(y_vars_sim): for traceid in range(number_trace): filename='simFig4_%s.csv' % (traceid+1) dfile = dfolder_sim + filename data = pd.read_csv(dfile) x_data=data[x_var_sim].values y_data=data[y_var_sim].values trace[plotid][traceid]={'dataX': x_data, 'dataY': y_data, 'lname': labels[traceid], 'linestyle':lines[0], 'marker':None, 'linecolor':colors[traceid],'y2':False} # Build the plots # maxH=8.75 inches, width 2.63-7.5 rows,cols = 1,1 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.8 # the top of the subplots of the figure 0.9 wspace = 0.4 # the amount of width reserved for space between subplots, # expressed as a fraction of the average axis width, 0.2 hspace = 0.6 # 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*6, 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} plots=[] for id in range(1): colid = id%2 rowid = id//2 lgdshow = True bbox_to_anchor = (1.1,1.25) trace[id].append(trace_org) iplot={'rowid':rowid, 'colid':colid, 'xlabel': x_label, 'ylabel':y_label[id], 'twiny':False, 'ylabel2':y_label[id],'labelcolor':colors[1], 'lgdshow': lgdshow, 'lgdloc':'best', 'bbox_to_anchor':bbox_to_anchor,'lgdncol': 2, '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)