Location: Imtiaz_IP3_2002 @ 2a5540078c04 / Simulation / Figure8 / Plot_Fig8.py

Author:
Leyla <noroozbabaee@gmail.com>
Date:
2022-03-21 23:51:54+13:00
Desc:
removed.
Permanent Source URI:
https://models.cellml.org/workspace/763/rawfile/2a5540078c04d07172f2517b5fd94e9f5c9cc41f/Simulation/Figure8/Plot_Fig8.py

# Author: Leyla Noroozbabaee
# Date: 12/12/2021
# To reproduce Figure 6 from original paper, the python file 'Fig8_sim.py' should be run.

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# Figure name
prefilename = 'Fig8'
figfile = 'Figure_8_origin'
# Read data from the files
x_name = 'Time'
y_name = [ 'vm']
z_name = ['I_inj']
# Experiment Set up for the Time of Stimulus
t_d_init = [2.36, 5.36]
t_d_end = [3, 6]

# Set figure dimension (width, height) in inches.
fw, fh = 15, 9
# Set subplots
subpRow, subpCol = 2, 1
ax, lns = {}, {}
# Set Title
tit = ['t_d = 5.36 s','t_d = 2.36 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 = 0.1, wspace = 0.1)
j = 0
# To include the extracted original data
Extracted_Original_Data = 1
x_base = [0.4, 0.6]
for i in range(2):
        filename = '%s_%s.csv' % (prefilename, i)
        data = pd.read_csv(filename)
        x_data = data [ x_name ]
        y_data = data [ y_name ]
        z_data = -75 + data [z_name ]
        axs [ i ].plot(x_data, y_data,'r')
        axs [ i ].plot(x_data, z_data, 'b')
        axs [ i ].set_xlim([ 0, 35 ])
        axs [ i ].set_ylim([ -78, -30 ])
        axs [ i ].set_ylabel('Membrane Voltage [mV]', fontsize=12)

        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)
        if Extracted_Original_Data == 1:
            filename = '%s_%d.csv' % ( figfile, i)
            print('filename', filename,j)
            data = pd.read_csv(filename)
            y_d = data['Curve1']
            x_d = x_base[i] + data['x']
            axs [ i ].plot(x_d, y_d, '.')
axs [ 1 ].set_xlabel('Time [min]', fontsize=12)
axs [ 0 ].set_xticks([ ])
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)


figfiles = '%s.png' % figfile
plt.savefig(figfiles)
plt.show()