Location: ICC_Lees_Green_2014 @ 881bedcb01f1 / Simulations / Plot_Fig3_Ano1.py

Author:
Leyla <lnor300>
Date:
2022-09-27 19:24:59+13:00
Desc:
..
Permanent Source URI:
https://models.physiomeproject.org/workspace/83c/rawfile/881bedcb01f191d01798f0d6266263a935197ee3/Simulations/Plot_Fig3_Ano1.py

# Author: Leyla Noroozbabaee
# Date: 12/09/2021
# To reproduce Figure 3 from original paper, the python file 'IAo1.py' should be run in the Python console in OpenCOR.

import matplotlib.pyplot as plt
import pandas as pd
from pathlib import Path

# Figure name
figfile = 'Fig3'

# To include the extracted data from the original paper
Fig3_extracted_data = 1
# Read data from the files
x_name = 'Time'
y_name = ['IAon1']
current = r'$I_{Aon1}(pA)$'
y_labels = ['%s' % current]
Vm = range(-100, 140, 40)


# Set figure dimension (width, height) in inches.
fw, fh = 15, 6

# Set subplots
subpRow, subpCol = 1, 4
ax, lns = {}, {}

# Set Title
tit = ['A $Ca_{Aon1}$ =$10^{-7}$ M', 'B $Ca_{Aon1}$ = $10^{-6}$ M','C $Ca_{Aon1}$ = $10^{-5}$ M', 'D']

# 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)
c = ['a', 'b', 'c', 'd']
for j in range(4):
    for i, V in enumerate(Vm):
        filename = '%s_%d_%s.csv' % (figfile, i, c [ j ])
        data = pd.read_csv(filename)
        x_data = data [ x_name ]
        y_data = data [ y_name ]
        axs [ j ].plot(x_data, y_data, color=cycle [ i % 7 ], label='%d mV ' % (V))
        plt.tick_params(direction='in', axis='both')
        axs [ j ].set_xlabel('Time (ms)', fontsize=labelfontsize)
        axs [ j ].set_title('%s' % (tit[j]))
        # To add the extracted data from original paper to your plot, modify the path to have access to the
        # "Fig3_extracted_data" folder.
        if Fig3_extracted_data == 1:
            filename = '%d_%s.csv' % (i, c [ j ])
            data_folder = Path("Fig3_extracted_data")
            file_to_open = data_folder / filename
            data = pd.read_csv(file_to_open)
            y_d = data [ 'Curve1' ]
            x_d = data ['x' ]
            axs [ j ].plot(x_d, y_d, 'k*')
        if j == 3:
            axs [ j ].axis([ 0, 20, -40, 60 ])
        else:
            axs [ j ].axis([ 0,15, -50, 50 ])
    axs [ 0 ].legend(loc='best', fontsize=lfontsize, frameon=False)
    axs [ 0 ].set_ylabel(y_labels [ 0 ], fontsize=labelfontsize)
    figfiles = '%s.png' % figfile
    plt.savefig(figfiles)
plt.show()