- Author:
- Leyla <noroozbabaee@gmail.com>
- Date:
- 2022-05-10 14:01:08+12:00
- Desc:
- Adding Tong_2011 to PMR
- Permanent Source URI:
- https://models.cellml.org/workspace/85c/rawfile/a03f680a69226c515cd789723c8036028406852b/Experiments/Figure_1/Fig1_plt.py
# Author: Leyla Noroozbabaee
# Date: 12/12/2021
# To reproduce Figure 6 from original paper, the python file 'Fig6_sim.py' should be run.
import matplotlib.pyplot as plt
import pandas as pd
from sklearn import preprocessing
import numpy as np
# Figure name
prefilename = 'Fig1'
figfile = 'Figure_8_origin'
# Read data from the files
# x_name = 'Time'
# y_name = 'fss'
# z_name = ['I_inj']
# current = r'$I_{Aon1}(pA)$'
# print(current)
# y_labels = [ '%s' % current ]
suffix = [ 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a' ]
c = ['a','b','c','d']
# Set figure dimension (width, height) in inches.
fw, fh = 15, 10
# Set subplots
subpRow, subpCol = 3, 2
ax, lns = {}, {}
# Set Title
tit = ['1s','2 s','1s','2 s','1s','2 s']
# This gives list with the colors from the cycle, which you can use to iterate over.
cycle = plt.rcParams [ 'axes.prop_cycle' ].by_key() [ 'color' ]
# Set subplots
lfontsize, labelfontsize = 10, 15 # legend, label fontsize
fig, axs = plt.subplots(subpRow, subpCol, figsize=(fw, fh), facecolor='w', edgecolor='k')
fig.subplots_adjust(hspace = .1, wspace=.1)
axs = axs.ravel()
var_name = ['Time','fss','dss','f1tc','f2tc','dtc','ical','v']
# y_name =['fss'];
x_base =[0.4, 0.6]
filename = '%s.csv' % (prefilename)
print(filename)
data = pd.read_csv(filename)
print('filename', filename)
data = pd.read_csv(filename)
time = data [ var_name[0] ]
fss_data = data [var_name[1]]
dss_data = data [var_name[2]]
f1tc_data = data [var_name[3]]
f2tc_data = data [var_name[4]]
dtc_data = data [var_name[5]]
ical_data = data [var_name[6]]
v_data = data [var_name[7]]
axs[0].plot( v_data, dss_data, 'b')
axs[1].plot( v_data, fss_data, 'b')
axs[2].plot( v_data, dtc_data, 'b')# y_data = data [ var [ i ] ]
axs[3].plot( v_data, f1tc_data, 'b', v_data, f2tc_data, 'k')
axs[5].plot( v_data, ical_data, 'k')
cycle = plt.rcParams [ 'axes.prop_cycle' ].by_key() [ 'color' ]
for i in range(5):
prefilename = 'Fig1_5'
filename5 = '%s_%s.csv' % (prefilename, 4)
data5 = pd.read_csv(filename5)
print('filename', filename5)
ical_data5 = data5 ['ical']
max_ical_data5 = max(data5 ['ical'])
filename = '%s_%s.csv' % (prefilename, i)
data = pd.read_csv(filename)
print('filename', filename)
time = data ['Time']
ical_data = data ['ical']
max_ical_data = max(data ['ical'])
ical_data1= data[ 'ical' ]/ max_ical_data5
# ical_data = preprocessing.normalize(np.array(ical_data).reshape(1, -1))
ical_tot_data = data ['I_Ca_tot']
ical_tot_data = preprocessing.normalize(np.array(ical_tot_data).reshape(1, -1))
v_data = data ['v']
itot_data = data ['I_tot']
itot_data = preprocessing.normalize(np.array(itot_data).reshape(1, -1))
axs [4].plot( time, ical_data, color=cycle [i % 4])#, label='%d mV ' % (V))
# axs [6 ].plot(time, itot_data [ 0 ], color=cycle [ i % 4 ]) # , label='%d mV ' % (V))
# axs [7 ].plot(time, ical_tot_data [ 0 ], color=cycle [ i % 4 ]) # , label='%d mV ' % (V))
figfiles = '%s.png' % (prefilename)
plt.savefig(figfiles)
plt.show()
# axs[i].text(0.1, 0.12, ' $I_{inj} = 0 mA$',
# verticalalignment='bottom', horizontalalignment='right',
# transform=axs [i].transAxes,
# color='k', fontsize=12)
#
# axs[i].text(0.53, 0.12, ' $I_{inj} = 2 mA$',
# verticalalignment='bottom', horizontalalignment='right',
# transform=axs [i].transAxes,
# color='k', fontsize=12)
# axs [ 0].text(0.1, 0.5, ' $t_{d} = 5.36 \ min$',
# verticalalignment='bottom', horizontalalignment='right',
# transform=axs [ 0 ].transAxes,
# color='k', fontsize=12)
#
# axs [ 1 ].text(0.1, 0.5, '$t_{d} = 2.36\ min$',
# verticalalignment='bottom', horizontalalignment='right',
# transform=axs [ 1 ].transAxes,
# color='k', fontsize=12)
# else:
# filename = '%s_%s.csv' % (prefilename, i)
# data = pd.read_csv(filename)
# x_data = data [ x_name ]
# y_data = data [ y_name ]
# # filename = '%d_%s.csv' % ( i, c [ j ])
# # print('filename', filename,j)
# #
# # data = pd.read_csv(filename)
# # y_d = data [ 'Curve1' ]
# # x_d = data ['x' ]
# axs [0 ].plot(x_data, y_data)
# # axs [0 ].set_xlim([ 0, 1.5])
# # axs [0 ].set_ylim([ -70, -20 ])
# # axs [ j ].plot(x_d, y_d, 'k*')
# # plt.tick_params(direction='in', axis='both'), label='%d mV ' % (V), color=cycle [ i % 7 ]
#
# # axs [ j ].set_xlabel('Time (ms)', fontsize=labelfontsize)
# # axs [ j ].set_title('%s' % (tit[j]))
#
# # axs.legend(loc='best', fontsize=lfontsize, frameon=False)
# # axs [ 0 ].set_ylabel(y_labels [ 0 ], fontsize=labelfontsize)
#
figfiles = '%s.png' % figfile
plt.savefig(figfiles)
# import numpy as np
# import matplotlib.pyplot as plt
#
# def SquareWave(n,xmin=0,xmax=35,ymin=0,Nx=1000,ymax=2,offset=2):
#
#
# x = np.sort(np.concatenate([np.arange(xmin, xmax)-1E-6,np.arange(xmin, xmax)+1E-6]))
# #You can use np.linspace(xmin,xmax,Nx) if you want the intermediate points
# y=np.array(x+n+offset,dtype=int)%2
#
# plt.plot(x, y)
# plt.axis([xmin, xmax, ymin, ymax])
# # plt.grid()
# plt.show()
# SquareWave(0, xmin=0, xmax=10, ymin=0, Nx=1000, ymax=2, offset=1)