Location: Computational analysis of the human sinus node action potential @ fdb895e885bc / Figure3-plot.py

Author:
Alan Garny <agarny@hellix.com>
Date:
2021-06-11 11:46:55+12:00
Desc:
Some minor cleaning up.
Permanent Source URI:
https://staging.physiomeproject.org/workspace/648/rawfile/fdb895e885bceb6247c07daeb81f919992d49837/Figure3-plot.py

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# read the csv file extracted from sedml file
data = pd.read_csv('Figure3.csv')

# define the x and y axis and match the units
X_name = 'environment/time'
y1_name = 'Membrane/V'
y2_name = 'i_CaL/i_CaL'
y3_name = 'i_Na/i_Na'
y4_name = 'i_NaK/i_NaK'
y5_name = 'Membrane/i_tot'
y6_name = 'i_Ks/i_Ks'
y7_name = 'i_Kr/i_Kr'
y8_name = 'i_CaT/i_CaT'
y9_name = 'i_f/i_f'
y10_name = 'i_NaCa/i_NaCa'

X1 = data[X_name] * 1000
Y1 = data[y1_name]
Y2 = data[y2_name] * 1000 / 57
Y3 = data[y3_name] * 1000 / 57
Y4 = data[y4_name] * 1000 / 57
Y5 = data[y5_name] * 1000 / 57
Y6 = data[y6_name] * 1000 / 57
Y7 = data[y7_name] * 1000 / 57
Y8 = data[y8_name] * 1000 / 57
Y9 = data[y9_name] * 1000 / 57
Y10 = data[y10_name] * 1000 / 57

plt.figure(figsize=(14, 14))

plt.subplot(211)
plt.plot(X1, Y1, 'navy', linestyle='-', label='', linewidth=3)
plt.grid()
x = np.array([3692, 3800, 3900, 4000, 4100, 4200, 4300, 4400])
values = [" ", "600", "700", "800", "900", "1000", "1100", "1200"]
plt.xlim(3692, 4410)
plt.ylim(-65, -25)
plt.xticks(x, values)
plt.yticks(np.arange(-60, -25, 10))

plt.tick_params(axis='both', labelsize=12)
plt.ylabel('V$_m$ (mV)', fontsize=14)
plt.title('A', loc='left', y=1.05, x=-0.06, fontsize=20)
plt.axvline(x=3745, linewidth=4, label='t$_{MDP}$', color='black')
plt.axvline(x=3845, linewidth=4, label='t$_{MDP}$+100 ms', linestyle='dotted', color='black')
plt.axvline(x=4365, linewidth=4, label='t$_{TOP}$', color='grey')
plt.legend(loc='best', fontsize=16)

plt.subplot(212)
plt.plot(X1, Y2, 'navy', linestyle='-', label='I$_{CaL}$', linewidth=3)
plt.plot(X1, Y3, 'red', linestyle='-', label='I$_{Na}$', linewidth=3)
plt.plot(X1, Y4, 'green', linestyle='-', label='I$_{NaK}$', linewidth=3)
plt.plot(X1, Y5, 'black', linestyle='-.', label='I$_{tot}$', linewidth=3)
plt.plot(X1, Y6, 'orange', linestyle='-', label='I$_{Ks}$', linewidth=3)
plt.plot(X1, Y7, 'purple', linestyle='-', label='I$_{Kr}$', linewidth=3)
plt.plot(X1, Y8, 'grey', linestyle='-', label='I$_{CaT}$', linewidth=3)
plt.plot(X1, Y9, 'black', linestyle='-', label='I$_{f}$', linewidth=3)
plt.plot(X1, Y10, 'blue', linestyle='-', label='I$_{NaCa}$', linewidth=3)

plt.grid()

x = np.array([3692, 3800, 3900, 4000, 4100, 4200, 4300, 4400])
values = [" ", "600", "700", "800", "900", "1000", "1100", "1200"]
plt.xlim(3692, 4410)
plt.ylim(-0.15, 0.2)
plt.xticks(x, values)
plt.xlabel('Time (ms)', fontsize=14)
plt.tick_params(axis='both', labelsize=12)
plt.ylabel('(pA/Pf)', fontsize=14)
plt.title('B', loc='left', y=1.05, x=-0.06, fontsize=20)
plt.legend(bbox_to_anchor=(0.22, 0.8, 0.5, 0.04), loc='best', fontsize=14,
           ncol=5, mode="expand", borderaxespad=0.)

plt.tight_layout(pad=0.5, w_pad=3, h_pad=3)
plt.savefig('Figure3.png')
plt.show()