Changed firing_characterization-jb.py to firing_characterization.py

and old firing_characterization file to firing_characterization_old.py
 also renamed ramp_examples.py as ramp_firing.py; cleaned up comments
 and code for rheobase_correlation.py, AUC_correlation.py, diversity_in_firing.py,
 ramp_firing.py, simulation_model_comparison.py
This commit is contained in:
nkoch1 2022-06-11 20:28:22 -04:00
parent cf0e2608bb
commit a0f64fd365
9 changed files with 506 additions and 717 deletions

View File

@ -93,14 +93,11 @@ def new_scatter(self, *args, **kwargs):
return FinalCollection return FinalCollection
Axes.scatter = new_scatter Axes.scatter = new_scatter
############## End hack. ############## ############## End hack. ##############
######################################################################################################################## ########################################################################################################################
#%% #%%
def boxplot_with_markers(ax,max_width, alteration='shift', msize=3): def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
# size =4
hlinewidth = 0.5 hlinewidth = 0.5
# ax.tick_params(axis='x', rotation=90)
model_names = ['RS pyramidal','RS inhibitory','FS', model_names = ['RS pyramidal','RS inhibitory','FS',
'RS pyramidal +$K_V1.1$','RS inhibitory +$K_V1.1$', 'RS pyramidal +$K_V1.1$','RS inhibitory +$K_V1.1$',
'FS +$K_V1.1$','Cb stellate','Cb stellate +$K_V1.1$', 'FS +$K_V1.1$','Cb stellate','Cb stellate +$K_V1.1$',
@ -123,7 +120,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
import matplotlib.colors import matplotlib.colors
colors = [matplotlib.colors.to_rgb(c) for c in colorslist] # sns.color_palette("hls", 14, desat=0.75)#[cm.tab20(i) for i in range(20)] colors = [matplotlib.colors.to_rgb(c) for c in colorslist]
clr_dict = {} clr_dict = {}
for m in range(len(model_names)): for m in range(len(model_names)):
clr_dict[model_names[m]] = colors[m] clr_dict[model_names[m]] = colors[m]
@ -141,9 +138,6 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
ax.plot([lim[0], lim[1]], [0, 0], ':r',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [0, 0], ':r',linewidth=hlinewidth)
ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth)
ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth)
# ax.get_legend().remove()
# sns.despine(trim=True, bottom=True, ax=ax)
# ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$')
ax.set_title("Shift ($\Delta V_{1/2}$)", y=1.05) ax.set_title("Shift ($\Delta V_{1/2}$)", y=1.05)
ax.set_xticklabels(['Na \nactivation', 'Na \ninactivation', 'K \nactivation', '$K_V1.1$ \nactivation', ax.set_xticklabels(['Na \nactivation', 'Na \ninactivation', 'K \nactivation', '$K_V1.1$ \nactivation',
'$K_V1.1$ \ninactivation', 'A \nactivation', 'A \ninactivation']) '$K_V1.1$ \ninactivation', 'A \nactivation', 'A \ninactivation'])
@ -153,25 +147,16 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
df = pd.read_csv('./Figures/Data/AUC_scale_corr.csv') df = pd.read_csv('./Figures/Data/AUC_scale_corr.csv')
# Add in points to show each observation # Add in points to show each observation
sns.swarmplot(y="corr", x="Slope (k)", hue="model", data=df, #dodge=True, sns.swarmplot(y="corr", x="Slope (k)", hue="model", data=df,
palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize,
order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation', order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation',
'$K_V1.1$ inactivation', 'A activation', 'A inactivation'], '$K_V1.1$ inactivation', 'A activation', 'A inactivation'],
hue_order=model_names, co2mk=Markers) hue_order=model_names, co2mk=Markers)
lim = ax.get_xlim() lim = ax.get_xlim()
# ax.plot([lim[0], lim[1]], [0,0], ':k')
ax.plot([lim[0], lim[1]], [0, 0], ':r',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [0, 0], ':r',linewidth=hlinewidth)
ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth)
ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth)
# Markers = ["o","s","v","^","<",">","p","h","P","X","D","*","8","o"]
# ax=fixlegend(ax, Markers)
# Tweak the visual presentation
# ax.get_legend().remove()
# ax.xaxis.grid(False)
# ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels())
# ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$')
ax.set_title("Slope (k)", y=1.05) ax.set_title("Slope (k)", y=1.05)
# sns.despine(trim=True, bottom=True, ax=ax)
ax.set_xticklabels(['Na \nactivation', 'Na \ninactivation', 'K \nactivation', '$K_V1.1$ \nactivation', ax.set_xticklabels(['Na \nactivation', 'Na \ninactivation', 'K \nactivation', '$K_V1.1$ \nactivation',
'$K_V1.1$ \ninactivation', 'A \nactivation', 'A \ninactivation']) '$K_V1.1$ \ninactivation', 'A \nactivation', 'A \ninactivation'])
elif alteration=='g': elif alteration=='g':
@ -180,7 +165,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
df = pd.read_csv('./Figures/Data/AUC_g_corr.csv') df = pd.read_csv('./Figures/Data/AUC_g_corr.csv')
# Add in points to show each observation # Add in points to show each observation
sns.swarmplot(y="corr", x="g", hue="model", data=df, #dodge=True, sns.swarmplot(y="corr", x="g", hue="model", data=df,
palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize,
order=['Na', 'K', '$K_V1.1$', 'A', 'Leak'], order=['Na', 'K', '$K_V1.1$', 'A', 'Leak'],
hue_order=model_names, co2mk=Markers) hue_order=model_names, co2mk=Markers)
@ -190,9 +175,6 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth)
ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth)
# Tweak the visual presentation # Tweak the visual presentation
# ax.xaxis.grid(False)
# sns.despine(trim=True, bottom=True, ax=ax)
# ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$')
ax.set_title("Conductance (g)", y=1.05) ax.set_title("Conductance (g)", y=1.05)
ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels()) ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels())
else: else:
@ -202,8 +184,6 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
sns.despine(trim=True, bottom=True, ax=ax) sns.despine(trim=True, bottom=True, ax=ax)
ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$') ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$')
# ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels())
# fixlegend(ax, Markers)
def model_legend(ax, marker_s_leg, pos, ncol): def model_legend(ax, marker_s_leg, pos, ncol):
colorslist = [ '#40A787', # cyan'# colorslist = [ '#40A787', # cyan'#
@ -220,15 +200,13 @@ def model_legend(ax, marker_s_leg, pos, ncol):
'#D03050' # pink '#D03050' # pink
] ]
import matplotlib.colors import matplotlib.colors
colors = [matplotlib.colors.to_rgb(c) for c in colorslist] #sns.color_palette("hls", 14, desat=0.75) #[cm.tab20(i) for i in range(20)] colors = [matplotlib.colors.to_rgb(c) for c in colorslist]
model_pos = {'Cb stellate':0, 'RS Inhibitory':1, 'FS':2, 'RS Pyramidal':3, model_pos = {'Cb stellate':0, 'RS Inhibitory':1, 'FS':2, 'RS Pyramidal':3,
'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':4, 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':4,
'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':5, 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':6, 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':5, 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':6,
'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':7, 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':8, 'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':7, 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':8,
'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':9, 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':9,
'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':10, 'STN':11} 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':10, 'STN':11}
Markers = ["o", "o", "o", "^", "^", "^", "D", "D", "D", "s", "s", "s"] Markers = ["o", "o", "o", "^", "^", "^", "D", "D", "D", "s", "s", "s"]
RS_p = mlines.Line2D([], [], color=colors[model_pos['RS Pyramidal']], marker=Markers[model_pos['RS Pyramidal']], markersize=marker_s_leg, linestyle='None', RS_p = mlines.Line2D([], [], color=colors[model_pos['RS Pyramidal']], marker=Markers[model_pos['RS Pyramidal']], markersize=marker_s_leg, linestyle='None',
label='RS pyramidal') label='RS pyramidal')
@ -290,8 +268,7 @@ def plot_AUC_alt(ax, model='FS', color1='red', color2='dodgerblue', alteration='
] ]
import matplotlib.colors import matplotlib.colors
colors = [matplotlib.colors.to_rgb(c) for c in colors = [matplotlib.colors.to_rgb(c) for c in colorslist]
colorslist] #sns.color_palette("hls", 14, desat=0.75)#[cm.tab20(i) for i in range(20)]
clr_dict = {} clr_dict = {}
for m in range(len(model_names)): for m in range(len(model_names)):
clr_dict[model_names[m]] = colors[m] clr_dict[model_names[m]] = colors[m]
@ -392,10 +369,7 @@ pad_w = 1.1
pad_h = 0.7 pad_h = 0.7
fig = plt.figure() fig = plt.figure()
# fig = plt.figure()
# fig.set_size_inches(cm2inch(17.6,10))
gs = fig.add_gridspec(3, 7, wspace=1.2, hspace=1.) gs = fig.add_gridspec(3, 7, wspace=1.2, hspace=1.)
# plt.subplots_adjust(hspace=0.8) #, wspace=0.6
ax0 = fig.add_subplot(gs[0,2:7]) ax0 = fig.add_subplot(gs[0,2:7])
ax0_ex = fig.add_subplot(gs[0,1]) ax0_ex = fig.add_subplot(gs[0,1])
ax0_fI = fig.add_subplot(gs[0,0]) ax0_fI = fig.add_subplot(gs[0,0])
@ -423,9 +397,6 @@ rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=line
rec = ax2_fI.add_patch(rec) rec = ax2_fI.add_patch(rec)
rec.set_clip_on(False) rec.set_clip_on(False)
# plot boxplots # plot boxplots
boxplot_with_markers(ax0,max_width, alteration='shift') boxplot_with_markers(ax0,max_width, alteration='shift')
boxplot_with_markers(ax1,max_width, alteration='slope') boxplot_with_markers(ax1,max_width, alteration='slope')
@ -455,78 +426,6 @@ ax2_ex.text(-0.8, 1.35, string.ascii_uppercase[7], transform=ax2_ex.transAxes, s
ax2.text(-0.075, 1.35, string.ascii_uppercase[8], transform=ax2.transAxes, size=10, weight='bold') ax2.text(-0.075, 1.35, string.ascii_uppercase[8], transform=ax2.transAxes, size=10, weight='bold')
#save #save
# plt.tight_layout(pad=0)
print(fig.dpi)
fig.set_size_inches(cm2inch(20.75,12)) fig.set_size_inches(cm2inch(20.75,12))
fig.savefig('./Figures/AUC_correlation.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi fig.savefig('./Figures/AUC_correlation.pdf', dpi=fig.dpi)
plt.show() plt.show()
# #%% alternative layout
# # boxplot_style()
# marker_s_leg = 8
# max_width = 10
# pad_x = 0.2
# pad_y= 0.4
# pad_w = 0.22
# pad_h = 0.6
#
# fig = plt.figure(figsize=(12,20))
# gs = fig.add_gridspec(3, 1, hspace=0.4, wspace=0.4)
# gs0 = gs[0].subgridspec(2, 4, wspace=0.6, hspace=1.)
# gs1 = gs[1].subgridspec(2, 4, wspace=0.6, hspace=1.)
# gs2 = gs[2].subgridspec(2, 4, wspace=0.6, hspace=1.)
# ax0 = fig.add_subplot(gs0[1,:])
# ax0_ex = fig.add_subplot(gs0[0,2:])
# ax0_fI = fig.add_subplot(gs0[0,:2])
# ax1 = fig.add_subplot(gs1[1,:])
# ax1_ex = fig.add_subplot(gs1[0,2:])
# ax1_fI = fig.add_subplot(gs1[0,:2])
# ax2 = fig.add_subplot(gs2[1,:])
# ax2_ex = fig.add_subplot(gs2[0,2:])
# ax2_fI = fig.add_subplot(gs2[0,:2])
#
#
# ax0_fI = plot_fI(ax0_fI, model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', type='shift', alt='s', color1='lightgrey', color2='k')
# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax0_fI.transAxes, color=color_dict['FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'], alpha=1, zorder=-1)
# rec = ax0_fI.add_patch(rec)
# rec.set_clip_on(False)
#
# ax1_fI = plot_fI(ax1_fI, model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', type='slope', alt='u', color1='lightgrey', color2='k')
# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax1_fI.transAxes, color=color_dict['FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'], alpha=1, zorder=-1)
# rec = ax1_fI.add_patch(rec)
# rec.set_clip_on(False)
#
# ax2_fI = plot_fI(ax2_fI, model='STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', type='g', alt='Leak', color1='lightgrey', color2='k')
# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax2_fI.transAxes, color=color_dict['STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'], alpha=1, zorder=-1)
# rec = ax2_fI.add_patch(rec)
# rec.set_clip_on(False)
#
# # label subplots with letters
# ax0_fI.text(-0.2, 1.38, string.ascii_uppercase[0], transform=ax0_fI.transAxes, size=16, weight='bold') #-0.09
# ax1_fI.text(-0.2, 1.38, string.ascii_uppercase[1], transform=ax1_fI.transAxes,size=16, weight='bold')
# ax2_fI.text(-0.2, 1.38, string.ascii_uppercase[2], transform=ax2_fI.transAxes,size=16, weight='bold')
#
# # plot boxplots
# boxplot_with_markers(ax0,max_width, alteration='shift')
# boxplot_with_markers(ax1,max_width, alteration='slope')
# boxplot_with_markers(ax2,max_width, alteration='g')
# # plot legend
# pos = (0.5, -1.)
# ncol = 6
# model_legend(ax2, marker_s_leg, pos, ncol)
#
# # # plot rheo across model for example alteration
# # plot_rheo_alt(ax0_ex,model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='red', color2='maroon', alteration='shift')
# # plot_rheo_alt(ax1_ex,model='Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='orchid', color2='purple',alteration='slope')
# # plot_rheo_alt(ax2_ex, model='Cb stellate', color1='darkviolet', color2='indigo', alteration='g')
# # plot_rheo_alt(ax0_ex,model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k', alteration='shift')
# # plot_rheo_alt(ax1_ex,model='Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k',alteration='slope')
# # plot_rheo_alt(ax2_ex, model='Cb stellate', color1='lightgrey', color2='k', alteration='g')
#
# # plot examples
# plot_AUC_alt(ax0_ex,model='FS', color1='lightgrey', color2='k', alteration='shift')
# plot_AUC_alt(ax1_ex,model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k',alteration='slope')
# plot_AUC_alt(ax2_ex, model='STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k', alteration='g')
# fig.savefig('AUC_correlation_2.pdf', bbox_inches='tight') #
# # plt.saveas(fig, 'AUC_correlation_2.png')
# plt.show()

View File

@ -4,7 +4,6 @@ import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec import matplotlib.gridspec as gridspec
from matplotlib.transforms import Bbox from matplotlib.transforms import Bbox
import string import string
# from plotstyle import plot_style
def cm2inch(*tupl): def cm2inch(*tupl):
@ -15,6 +14,7 @@ def cm2inch(*tupl):
return tuple(i/inch for i in tupl) return tuple(i/inch for i in tupl)
plt.rcParams['xtick.labelsize'] = 6 plt.rcParams['xtick.labelsize'] = 6
plt.rcParams['ytick.labelsize'] = 6 plt.rcParams['ytick.labelsize'] = 6
#### from https://gist.github.com/dmeliza/3251476 ##################################################################### #### from https://gist.github.com/dmeliza/3251476 #####################################################################
from matplotlib.offsetbox import AnchoredOffsetbox from matplotlib.offsetbox import AnchoredOffsetbox
class AnchoredScaleBar(AnchoredOffsetbox): class AnchoredScaleBar(AnchoredOffsetbox):
@ -128,7 +128,7 @@ def plot_fI(ax, model='RS Pyramidal'):
#%% #%%
# plot layout # plot layout
fig = plt.figure() #figsize=cm2inch(17.6,17.6) fig = plt.figure()
gs0 = fig.add_gridspec(3, 2, wspace=0.3, hspace=0) gs0 = fig.add_gridspec(3, 2, wspace=0.3, hspace=0)
gs00 = gs0[:,0].subgridspec(6, 3, wspace=1.5, hspace=1.5) gs00 = gs0[:,0].subgridspec(6, 3, wspace=1.5, hspace=1.5)
gs01 = gs0[:,1].subgridspec(6, 3, wspace=1.2, hspace=1.3) gs01 = gs0[:,1].subgridspec(6, 3, wspace=1.2, hspace=1.3)
@ -187,10 +187,8 @@ for i in range(0,len(models)):
spike_axs[i].text(-0.18, 1.08, string.ascii_uppercase[i], transform=spike_axs[i].transAxes, size=10, weight='bold') spike_axs[i].text(-0.18, 1.08, string.ascii_uppercase[i], transform=spike_axs[i].transAxes, size=10, weight='bold')
# save # save
# fig.savefig('./Figures/diversity_in_firing.pdf', bbox_inches='tight')
print(fig.dpi)
fig.set_size_inches(cm2inch(17.6,20)) fig.set_size_inches(cm2inch(17.6,20))
fig.savefig('./Figures/diversity_in_firing.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi fig.savefig('./Figures/diversity_in_firing.pdf', dpi=fig.dpi)
plt.show() plt.show()

View File

@ -1,386 +0,0 @@
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import matplotlib.ticker as ticker
from matplotlib.colors import colorConverter as cc
from matplotlib.colors import to_hex
import string
# from plotstyle import plot_style
from plotstyle import scheme_style
colorslist = ['#40A787', # cyan'#
'#F0D730', # yellow
'#C02717', # red
'#007030', # dark green
'#AAB71B', # lightgreen
'#008797', # light blue
'#F78017', # orange
'#478010', # green
'#53379B', # purple
'#2060A7', # blue
'#873770', # magenta
'#D03050' # pink
]
def cm2inch(*tupl):
inch = 2.54
if isinstance(tupl[0], tuple):
return tuple(i/inch for i in tupl[0])
else:
return tuple(i/inch for i in tupl)
def show_spines(ax, spines='lrtb'):
""" Show and hide spines.
From github.com/janscience/plottools.git spines.py
Parameters
----------
ax: matplotlib figure, matplotlib axis, or list of matplotlib axes
Axis on which spine and ticks visibility is manipulated.
If figure, then apply manipulations on all axes of the figure.
If list of axes, apply manipulations on each of the given axes.
spines: string
Specify which spines and ticks should be shown.
All other ones or hidden.
'l' is the left spine, 'r' the right spine,
't' the top one and 'b' the bottom one.
E.g. 'lb' shows the left and bottom spine, and hides the top
and and right spines, as well as their tick marks and labels.
'' shows no spines at all.
'lrtb' shows all spines and tick marks.
Examples
--------
```py
import matplotlib.pyplot as plt
import plottools.spines
fig, (ax0, ax1, ax2) = plt.subplots(1, 3)
ax0.show_spines('lb')
ax1.show_spines('bt')
ax2.show_spines('tr')
```
![show](figures/spines-show.png)
"""
# collect spine visibility:
xspines = []
if 't' in spines:
xspines.append('top')
if 'b' in spines:
xspines.append('bottom')
yspines = []
if 'l' in spines:
yspines.append('left')
if 'r' in spines:
yspines.append('right')
# collect axes:
if isinstance(ax, (list, tuple, np.ndarray)):
axs = ax
elif hasattr(ax, 'get_axes'):
# ax is figure:
axs = ax.get_axes()
else:
axs = [ax]
if not isinstance(axs, (list, tuple)):
axs = [axs]
for ax in axs:
# hide spines:
ax.spines['top'].set_visible('top' in xspines)
ax.spines['bottom'].set_visible('bottom' in xspines)
ax.spines['left'].set_visible('left' in yspines)
ax.spines['right'].set_visible('right' in yspines)
# ticks:
if len(xspines) == 0:
ax.xaxis.set_ticks_position('none')
ax.xaxis.label.set_visible(False)
ax.xaxis._orig_major_locator = ax.xaxis.get_major_locator()
ax.xaxis.set_major_locator(ticker.NullLocator())
else:
if hasattr(ax.xaxis, '_orig_major_locator'):
ax.xaxis.set_major_locator(ax.xaxis._orig_major_locator)
delattr(ax.xaxis, '_orig_major_locator')
elif isinstance(ax.xaxis.get_major_locator(), ticker.NullLocator):
ax.xaxis.set_major_locator(ticker.AutoLocator())
if len(xspines) == 1:
ax.xaxis.set_ticks_position(xspines[0])
ax.xaxis.set_label_position(xspines[0])
else:
ax.xaxis.set_ticks_position('both')
ax.xaxis.set_label_position('bottom')
if len(yspines) == 0:
ax.yaxis.set_ticks_position('none')
ax.yaxis.label.set_visible(False)
ax.yaxis._orig_major_locator = ax.yaxis.get_major_locator()
ax.yaxis.set_major_locator(ticker.NullLocator())
else:
if hasattr(ax.yaxis, '_orig_major_locator'):
ax.yaxis.set_major_locator(ax.yaxis._orig_major_locator)
delattr(ax.yaxis, '_orig_major_locator')
elif isinstance(ax.yaxis.get_major_locator(), ticker.NullLocator):
ax.yaxis.set_major_locator(ticker.AutoLocator())
if len(yspines) == 1:
ax.yaxis.set_ticks_position(yspines[0])
ax.yaxis.set_label_position(yspines[0])
else:
ax.yaxis.set_ticks_position('both')
ax.yaxis.set_label_position('left')
def lighter(color, lightness):
""" Make a color lighter.
From github.com/janscience/plottools.git colors.py
![lighter](figures/colors-lighter.png)
Parameters
----------
color: dict or matplotlib color spec
A matplotlib color (hex string, name color string, rgb tuple)
or a dictionary with an 'color' or 'facecolor' key.
lightness: float
The smaller the lightness, the lighter the returned color.
A lightness of 0 returns white.
A lightness of 1 leaves the color untouched.
A lightness of 2 returns black.
Returns
-------
color: string or dict
The lighter color as a hexadecimal RGB string (e.g. '#rrggbb').
If `color` is a dictionary, a copy of the dictionary is returned
with the value of 'color' or 'facecolor' set to the lighter color.
Examples
--------
For 40% lightness of blue do
```py
import plottools.colors as c
colors = c.palettes['muted']
lightblue = c.lighter(colors['blue'], 0.4)
```
"""
try:
c = color['color']
cd = dict(**color)
cd['color'] = lighter(c, lightness)
return cd
except (KeyError, TypeError):
try:
c = color['facecolor']
cd = dict(**color)
cd['facecolor'] = lighter(c, lightness)
return cd
except (KeyError, TypeError):
if lightness > 2:
lightness = 2
if lightness > 1:
return darker(color, 2.0-lightness)
if lightness < 0:
lightness = 0
r, g, b = cc.to_rgb(color)
rl = r + (1.0-lightness)*(1.0 - r)
gl = g + (1.0-lightness)*(1.0 - g)
bl = b + (1.0-lightness)*(1.0 - b)
return to_hex((rl, gl, bl)).upper()
def plot_sqrt(ax, a=1, b=0.2, c=100, d=0):
x = np.linspace(0, 1, 10000)
y = c*np.sqrt(a*(x - b)) + d
ax.plot(x, y)
ax.set_xlabel('Current [nA]')
ax.set_ylabel('Frequency [Hz]')
ax.set_xlim(0,1)
ax.set_ylim(0, ax.get_ylim()[1])
def plot_AUC(ax, a=1, b=0.2, c=180, d=0, width=0.2):
x = np.linspace(0, 1, 1000)
y = c*np.sqrt(a*(x - b)) + d
ax.plot(x, y, colorslist[9])
ax.set_xlabel('Current [nA]')
ax.set_ylabel('Frequency [Hz]')
ax.fill_between(x, y, where=(x<=b+width), color=lighter(colorslist[9], 0.3))
ax.text(0.3, 15, 'AUC', ha='center')
ax.annotate('', (0.2, 10), (0, 10), arrowprops=dict(arrowstyle="<->"))
ax.text(0.1, 20, 'rheobase', ha='center')
ax.set_xlim(0, 0.5)
ax.set_ylim(0, 100)
ax.yaxis.set_major_locator(ticker.MultipleLocator(50))
def plot_diff_sqrt(ax, a=1, b=0.2, c=100, d=0, a2=1, b2=0.2, c2=100, d2=0):
show_spines(ax, 'lb')
x = np.linspace(0, 1, 10000)
y = c*np.sqrt(a*(x - b)) + d
y2 = c2 * np.sqrt(a2 * (x - b2)) + d2
ax.plot(x, y, colorslist[9])
ax.plot(x, y2, colorslist[2])
ax.set_xlim(0,1)
ax.set_ylim(0, ax.get_ylim()[1])
ax.set_xticks([])
ax.set_yticks([])
def plot_quadrant(ax):
ax.spines['left'].set_position('zero')
ax.spines['bottom'].set_position('zero')
ax.text(1.2, -0.15, '$\\Delta$ rheobase', ha='right')
ax.text(-0.03, 0.7, '$\\Delta$ AUC', ha='right', rotation=90)
ax.tick_params(length=0)
ax.set_xlim(-1, 1)
ax.set_ylim(-1, 1)
ax.annotate('', (1, 0), (-1, 0), arrowprops=dict(arrowstyle="->"))
ax.annotate('', (0, 1), (0, -1), arrowprops=dict(arrowstyle="->"))
ax.set_xticks([-0.5, 0.5])
a = ax.get_xticks().tolist()
a[0] = '\u2212'
a[1] = '+'
ax.set_xticklabels(a)
ax.set_yticks([-0.5, 0.5])
b = ax.get_xticks().tolist()
b[0] = '\u2212'
b[1] = '+'
ax.set_yticklabels(b)
# ax.tick_params(labelsize=16)
# ax.set_yticks([0])
# ax.axis('off')
scheme_style()
#%% with legend
fig = plt.figure(figsize=cm2inch(7, 12))
gs = gridspec.GridSpec(3,6, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6)
ax1 = fig.add_subplot(gs[0,1:])
show_spines(ax1, 'lb')
plot_AUC(ax1, width=0.2)
ax3 = fig.add_subplot(gs[1:, :])
# add panel letter labels
# ax_list = fig.axes
# i =0
# for a in ax_list:
# a.text(-0.25, 1.08, string.ascii_uppercase[i], transform=a.transAxes,size=16, weight='bold')
# i += 1
ax1.text(-0.4, 1.2, string.ascii_uppercase[0], transform=ax1.transAxes, size=16, weight='bold')
ax3.text(-0.15, 1.05, string.ascii_uppercase[1], transform=ax3.transAxes, size=16, weight='bold')
show_spines(ax3, '')
#ax3.set_ylabel('$\\Delta$ AUC', rotation='vertical')
#ax3.set_xlabel('$\\Delta$ rheobase')
plot_quadrant(ax3) # plot delineation into quadrants
inset_ylim = (0, 100)
# top left
lfsize = 8
ax3.text(x=-0.9, y=0.7, s='$\\uparrow$ AUC\n$\\downarrow$ rheobase', fontsize=lfsize)
ax3.text(-0.95, 0.35, 'GOF', ha='right')
ax3_TL = ax3.inset_axes([0.07, 0.6, 0.3, 0.2])
plot_diff_sqrt(ax3_TL, b2=0.1, c2=200)
ax3_TL.set_ylim(inset_ylim)
# top right
ax3.text(x=0.22, y=0.7, s='$\\uparrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize)
ax3.text(0.95, 0.35, 'LOF/\nGOF?')
ax3_TR = ax3.inset_axes([0.63, 0.6, 0.3, 0.2])
plot_diff_sqrt(ax3_TR, b2=0.4, c2=200)
ax3_TR.set_ylim(inset_ylim)
# bottom left
ax3.text(x=-0.9, y=-0.95, s='$\\downarrow$ AUC\n$\downarrow$ rheobase', fontsize=lfsize)
ax3.text(-0.95, -0.55, 'GOF/\nLOF?', ha='right')
ax3_BL = ax3.inset_axes([0.07, 0.15, 0.3, 0.2])
plot_diff_sqrt(ax3_BL, b2=0.07, c2=65)
ax3_BL.set_ylim(inset_ylim)
# bottom right
ax3.text(x=0.22, y=-0.95, s='$\\downarrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize)
ax3.text(0.95, -0.55, 'LOF')
ax3_BR = ax3.inset_axes([0.63, 0.15, 0.3, 0.2])
plot_diff_sqrt(ax3_BR, b2=0.4, c2=60)
ax3_BR.set_ylim(inset_ylim)
import matplotlib.lines as mlines
wt = mlines.Line2D([], [], color=colorslist[9], linestyle='-',label='WT')
mut = mlines.Line2D([], [], color=colorslist[2], linestyle='-',label='Altered')
pos = (0.575, 0.05)
ncol = 2
fig.legend(handles=[wt, mut], loc='center', bbox_to_anchor=pos, ncol=ncol, frameon=False, fontsize=8)
fig.set_size_inches(cm2inch(8.5,12))
fig.savefig('./Figures/firing_characterization.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi
plt.show()
#%% with arrows
fig = plt.figure(figsize=cm2inch(7, 12))
gs = gridspec.GridSpec(3,6, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6)
ax1 = fig.add_subplot(gs[0,1:])
show_spines(ax1, 'lb')
plot_AUC(ax1, width=0.2)
ax3 = fig.add_subplot(gs[1:, :])
# add panel letter labels
# ax_list = fig.axes
# i =0
# for a in ax_list:
# a.text(-0.25, 1.08, string.ascii_uppercase[i], transform=a.transAxes,size=16, weight='bold')
# i += 1
ax1.text(-0.4, 1.2, string.ascii_uppercase[0], transform=ax1.transAxes, size=16, weight='bold')
ax3.text(-0.15, 1.05, string.ascii_uppercase[1], transform=ax3.transAxes, size=16, weight='bold')
show_spines(ax3, '')
#ax3.set_ylabel('$\\Delta$ AUC', rotation='vertical')
#ax3.set_xlabel('$\\Delta$ rheobase')
plot_quadrant(ax3) # plot delineation into quadrants
inset_ylim = (0, 100)
# top left
lfsize = 8
ax3.text(x=-0.9, y=0.7, s='$\\uparrow$ AUC\n$\\downarrow$ rheobase', fontsize=lfsize)
ax3.text(-0.95, 0.35, 'GOF', ha='right')
ax3_TL = ax3.inset_axes([0.07, 0.6, 0.3, 0.2])
plot_diff_sqrt(ax3_TL, b2=0.09, c2=200)
ax3_TL.set_ylim(inset_ylim)
ax3_TL.annotate('', (0.25, 7), (0.085, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
ax3_TL.annotate('', (0.55, 55), (0.3, 90), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
# top right
ax3.text(x=0.22, y=0.7, s='$\\uparrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize)
ax3.text(0.95, 0.35, 'LOF/\nGOF?')
ax3_TR = ax3.inset_axes([0.63, 0.6, 0.3, 0.2])
plot_diff_sqrt(ax3_TR, b2=0.4, c2=200)
ax3_TR.set_ylim(inset_ylim)
ax3_TR.annotate('', (0.17, 7), (0.41, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
ax3_TR.annotate('', (0.8, 70), (0.6, 90), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
# bottom left
ax3.text(x=-0.9, y=-0.95, s='$\\downarrow$ AUC\n$\downarrow$ rheobase', fontsize=lfsize)
ax3.text(-0.95, -0.55, 'GOF/\nLOF?', ha='right')
ax3_BL = ax3.inset_axes([0.07, 0.15, 0.3, 0.2])
plot_diff_sqrt(ax3_BL, b2=0.06, c2=65)
ax3_BL.set_ylim(inset_ylim)
ax3_BL.annotate('', (0.25, 7), (0.07, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
ax3_BL.annotate('', (0.8, 80), (0.85, 55), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
# bottom right
ax3.text(x=0.22, y=-0.95, s='$\\downarrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize)
ax3.text(0.95, -0.55, 'LOF')
ax3_BR = ax3.inset_axes([0.63, 0.15, 0.3, 0.2])
plot_diff_sqrt(ax3_BR, b2=0.4, c2=60)
ax3_BR.set_ylim(inset_ylim)
ax3_BR.annotate('', (0.18, 7), (0.42, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
ax3_BR.annotate('', (0.7, 75), (0.8, 37.5), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
fig.set_size_inches(cm2inch(8.5,12))
fig.savefig('./Figures/firing_characterization_arrows.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi
plt.show()

Binary file not shown.

View File

@ -1,10 +1,26 @@
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec import matplotlib.gridspec as gridspec
import matplotlib.ticker as ticker
from matplotlib.colors import colorConverter as cc
from matplotlib.colors import to_hex
import string import string
# from plotstyle import plot_style
from plotstyle import scheme_style from plotstyle import scheme_style
colorslist = ['#40A787', # cyan'#
'#F0D730', # yellow
'#C02717', # red
'#007030', # dark green
'#AAB71B', # lightgreen
'#008797', # light blue
'#F78017', # orange
'#478010', # green
'#53379B', # purple
'#2060A7', # blue
'#873770', # magenta
'#D03050' # pink
]
def cm2inch(*tupl): def cm2inch(*tupl):
inch = 2.54 inch = 2.54
if isinstance(tupl[0], tuple): if isinstance(tupl[0], tuple):
@ -12,6 +28,165 @@ def cm2inch(*tupl):
else: else:
return tuple(i/inch for i in tupl) return tuple(i/inch for i in tupl)
def show_spines(ax, spines='lrtb'):
""" Show and hide spines.
From github.com/janscience/plottools.git spines.py
Parameters
----------
ax: matplotlib figure, matplotlib axis, or list of matplotlib axes
Axis on which spine and ticks visibility is manipulated.
If figure, then apply manipulations on all axes of the figure.
If list of axes, apply manipulations on each of the given axes.
spines: string
Specify which spines and ticks should be shown.
All other ones or hidden.
'l' is the left spine, 'r' the right spine,
't' the top one and 'b' the bottom one.
E.g. 'lb' shows the left and bottom spine, and hides the top
and and right spines, as well as their tick marks and labels.
'' shows no spines at all.
'lrtb' shows all spines and tick marks.
Examples
--------
```py
import matplotlib.pyplot as plt
import plottools.spines
fig, (ax0, ax1, ax2) = plt.subplots(1, 3)
ax0.show_spines('lb')
ax1.show_spines('bt')
ax2.show_spines('tr')
```
![show](figures/spines-show.png)
"""
# collect spine visibility:
xspines = []
if 't' in spines:
xspines.append('top')
if 'b' in spines:
xspines.append('bottom')
yspines = []
if 'l' in spines:
yspines.append('left')
if 'r' in spines:
yspines.append('right')
# collect axes:
if isinstance(ax, (list, tuple, np.ndarray)):
axs = ax
elif hasattr(ax, 'get_axes'):
# ax is figure:
axs = ax.get_axes()
else:
axs = [ax]
if not isinstance(axs, (list, tuple)):
axs = [axs]
for ax in axs:
# hide spines:
ax.spines['top'].set_visible('top' in xspines)
ax.spines['bottom'].set_visible('bottom' in xspines)
ax.spines['left'].set_visible('left' in yspines)
ax.spines['right'].set_visible('right' in yspines)
# ticks:
if len(xspines) == 0:
ax.xaxis.set_ticks_position('none')
ax.xaxis.label.set_visible(False)
ax.xaxis._orig_major_locator = ax.xaxis.get_major_locator()
ax.xaxis.set_major_locator(ticker.NullLocator())
else:
if hasattr(ax.xaxis, '_orig_major_locator'):
ax.xaxis.set_major_locator(ax.xaxis._orig_major_locator)
delattr(ax.xaxis, '_orig_major_locator')
elif isinstance(ax.xaxis.get_major_locator(), ticker.NullLocator):
ax.xaxis.set_major_locator(ticker.AutoLocator())
if len(xspines) == 1:
ax.xaxis.set_ticks_position(xspines[0])
ax.xaxis.set_label_position(xspines[0])
else:
ax.xaxis.set_ticks_position('both')
ax.xaxis.set_label_position('bottom')
if len(yspines) == 0:
ax.yaxis.set_ticks_position('none')
ax.yaxis.label.set_visible(False)
ax.yaxis._orig_major_locator = ax.yaxis.get_major_locator()
ax.yaxis.set_major_locator(ticker.NullLocator())
else:
if hasattr(ax.yaxis, '_orig_major_locator'):
ax.yaxis.set_major_locator(ax.yaxis._orig_major_locator)
delattr(ax.yaxis, '_orig_major_locator')
elif isinstance(ax.yaxis.get_major_locator(), ticker.NullLocator):
ax.yaxis.set_major_locator(ticker.AutoLocator())
if len(yspines) == 1:
ax.yaxis.set_ticks_position(yspines[0])
ax.yaxis.set_label_position(yspines[0])
else:
ax.yaxis.set_ticks_position('both')
ax.yaxis.set_label_position('left')
def lighter(color, lightness):
""" Make a color lighter.
From github.com/janscience/plottools.git colors.py
![lighter](figures/colors-lighter.png)
Parameters
----------
color: dict or matplotlib color spec
A matplotlib color (hex string, name color string, rgb tuple)
or a dictionary with an 'color' or 'facecolor' key.
lightness: float
The smaller the lightness, the lighter the returned color.
A lightness of 0 returns white.
A lightness of 1 leaves the color untouched.
A lightness of 2 returns black.
Returns
-------
color: string or dict
The lighter color as a hexadecimal RGB string (e.g. '#rrggbb').
If `color` is a dictionary, a copy of the dictionary is returned
with the value of 'color' or 'facecolor' set to the lighter color.
Examples
--------
For 40% lightness of blue do
```py
import plottools.colors as c
colors = c.palettes['muted']
lightblue = c.lighter(colors['blue'], 0.4)
```
"""
try:
c = color['color']
cd = dict(**color)
cd['color'] = lighter(c, lightness)
return cd
except (KeyError, TypeError):
try:
c = color['facecolor']
cd = dict(**color)
cd['facecolor'] = lighter(c, lightness)
return cd
except (KeyError, TypeError):
if lightness > 2:
lightness = 2
if lightness > 1:
return darker(color, 2.0-lightness)
if lightness < 0:
lightness = 0
r, g, b = cc.to_rgb(color)
rl = r + (1.0-lightness)*(1.0 - r)
gl = g + (1.0-lightness)*(1.0 - g)
bl = b + (1.0-lightness)*(1.0 - b)
return to_hex((rl, gl, bl)).upper()
def plot_sqrt(ax, a=1, b=0.2, c=100, d=0): def plot_sqrt(ax, a=1, b=0.2, c=100, d=0):
x = np.linspace(0, 1, 10000) x = np.linspace(0, 1, 10000)
y = c*np.sqrt(a*(x - b)) + d y = c*np.sqrt(a*(x - b)) + d
@ -21,162 +196,173 @@ def plot_sqrt(ax, a=1, b=0.2, c=100, d=0):
ax.set_xlim(0,1) ax.set_xlim(0,1)
ax.set_ylim(0, ax.get_ylim()[1]) ax.set_ylim(0, ax.get_ylim()[1])
def plot_AUC(ax, a=1, b=0.2, c=100, d=0, width=0.2): def plot_AUC(ax, a=1, b=0.2, c=180, d=0, width=0.2):
x = np.linspace(0, 1, 10000) x = np.linspace(0, 1, 1000)
y = c*np.sqrt(a*(x - b)) + d y = c*np.sqrt(a*(x - b)) + d
ax.plot(x, y, 'k') ax.plot(x, y, colorslist[9])
ax.set_xlabel('Current [nA]') ax.set_xlabel('Current [nA]')
ax.set_ylabel('Frequency [Hz]') ax.set_ylabel('Frequency [Hz]')
ax.fill_between(x,y, where=(x<=b+width), color='c') ax.fill_between(x, y, where=(x<=b+width), color=lighter(colorslist[9], 0.3))
ax.set_xlim(0,1) ax.text(0.3, 15, 'AUC', ha='center')
ax.annotate('', (0.2, 10), (0, 10), arrowprops=dict(arrowstyle="<->"))
ax.text(0.1, 20, 'rheobase', ha='center')
ax.set_xlim(0, 0.5)
ax.set_ylim(0, 100) ax.set_ylim(0, 100)
ax.yaxis.set_major_locator(ticker.MultipleLocator(50)) ax.yaxis.set_major_locator(ticker.MultipleLocator(50))
def plot_diff_sqrt(ax, a=1, b=0.2, c=100, d=0, a2=1, b2=0.2, c2=100, d2=0): def plot_diff_sqrt(ax, a=1, b=0.2, c=100, d=0, a2=1, b2=0.2, c2=100, d2=0):
show_spines(ax, 'lb')
x = np.linspace(0, 1, 10000) x = np.linspace(0, 1, 10000)
y = c*np.sqrt(a*(x - b)) + d y = c*np.sqrt(a*(x - b)) + d
y2 = c2 * np.sqrt(a2 * (x - b2)) + d2 y2 = c2 * np.sqrt(a2 * (x - b2)) + d2
ax.plot(x, y, 'k') ax.plot(x, y, colorslist[9])
ax.plot(x, y2, 'b') ax.plot(x, y2, colorslist[2])
ax.set_xlim(0,1) ax.set_xlim(0,1)
ax.set_ylim(0, ax.get_ylim()[1]) ax.set_ylim(0, ax.get_ylim()[1])
ax.set_xticks([]) ax.set_xticks([])
ax.set_yticks([]) ax.set_yticks([])
def plot_quadrant(ax): def plot_quadrant(ax):
ax.plot(ax.get_xlim(),[0,0], '--k', linewidth=1.25) ax.spines['left'].set_position('zero')
ax.plot([0,0],ax.get_ylim(), '--k', linewidth=1.25) ax.spines['bottom'].set_position('zero')
ax.tick_params(axis=u'both', which=u'both', length=0) ax.text(1.2, -0.15, '$\\Delta$ rheobase', ha='right')
ax.set_xticks([-0.55, 0, 0.55]) ax.text(-0.03, 0.7, '$\\Delta$ AUC', ha='right', rotation=90)
ax.tick_params(length=0)
ax.set_xlim(-1, 1)
ax.set_ylim(-1, 1)
ax.annotate('', (1, 0), (-1, 0), arrowprops=dict(arrowstyle="->"))
ax.annotate('', (0, 1), (0, -1), arrowprops=dict(arrowstyle="->"))
ax.set_xticks([-0.5, 0.5])
a = ax.get_xticks().tolist() a = ax.get_xticks().tolist()
a[0] = '\u2212' a[0] = '\u2212'
a[1] = 0 a[1] = '+'
a[2] = '+'
ax.set_xticklabels(a) ax.set_xticklabels(a)
ax.set_yticks([-0.55, 0, 0.55]) ax.set_yticks([-0.5, 0.5])
b = ax.get_xticks().tolist() b = ax.get_xticks().tolist()
b[0] = '\u2212' b[0] = '\u2212'
b[1] = 0 b[1] = '+'
b[2] = '+'
ax.set_yticklabels(b) ax.set_yticklabels(b)
# ax.tick_params(labelsize=16)
# ax.set_yticks([0])
# ax.axis('off')
# plot_style() # scheme_style()
scheme_style() #%% with legend
fig = plt.figure(figsize=cm2inch(7, 12)) fig = plt.figure(figsize=cm2inch(7, 12))
gs = gridspec.GridSpec(3,2, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6) gs = gridspec.GridSpec(3,6, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6)
ax1 = fig.add_subplot(gs[0,:]) ax1 = fig.add_subplot(gs[0,1:])
show_spines(ax1, 'lb')
plot_AUC(ax1, width=0.2) plot_AUC(ax1, width=0.2)
ax3 = fig.add_subplot(gs[1:, :]) ax3 = fig.add_subplot(gs[1:, :])
# add panel letter labels # add panel letter labels
ax_list = fig.axes ax1.text(-0.4, 1.2, string.ascii_uppercase[0], transform=ax1.transAxes, size=16, weight='bold')
i =0 ax3.text(-0.15, 1.05, string.ascii_uppercase[1], transform=ax3.transAxes, size=16, weight='bold')
for a in ax_list:
a.text(-0.18, 1.08, string.ascii_uppercase[i], transform=a.transAxes,size=16, weight='bold') show_spines(ax3, '')
i += 1
ax3.set_ylabel('$\Delta$ AUC')
ax3.set_xlabel('$\Delta$ rheobase')
ax3.set_xlim(-1, 1)
ax3.set_ylim(-1, 1)
plot_quadrant(ax3) # plot delineation into quadrants plot_quadrant(ax3) # plot delineation into quadrants
inset_ylim = (0, 100) inset_ylim = (0, 100)
# top left # top left
lfsize = 8 lfsize = 8
ax3.text(x=-0.75, y=0.25, s=r'''$\uparrow$ AUC ax3.text(x=-0.9, y=0.7, s='$\\uparrow$ AUC\n$\\downarrow$ rheobase', fontsize=lfsize)
$\downarrow$ rheobase''', fontsize=lfsize) ax3.text(-0.95, 0.35, 'GOF', ha='right')
ax3_TL = ax3.inset_axes([0, 0.8, 0.3, 0.2]) ax3_TL = ax3.inset_axes([0.07, 0.6, 0.3, 0.2])
plot_diff_sqrt(ax3_TL, b2=0.1, c2=200) plot_diff_sqrt(ax3_TL, b2=0.1, c2=200)
ax3_TL.set_ylim(inset_ylim) ax3_TL.set_ylim(inset_ylim)
# top right # top right
ax3.text(x=0.25, y=0.25, s=r'''$\uparrow$ AUC ax3.text(x=0.22, y=0.7, s='$\\uparrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize)
$\uparrow$ rheobase''', fontsize=lfsize) ax3.text(0.95, 0.35, 'LOF/\nGOF?')
ax3_TR = ax3.inset_axes([0.7, 0.8, 0.3, 0.2]) ax3_TR = ax3.inset_axes([0.63, 0.6, 0.3, 0.2])
plot_diff_sqrt(ax3_TR, b2=0.4, c2=200) plot_diff_sqrt(ax3_TR, b2=0.4, c2=200)
ax3_TR.set_ylim(inset_ylim) ax3_TR.set_ylim(inset_ylim)
# bottom left # bottom left
ax3.text(x=-0.75, y=-0.35, s=r'''$\downarrow$ AUC ax3.text(x=-0.9, y=-0.95, s='$\\downarrow$ AUC\n$\downarrow$ rheobase', fontsize=lfsize)
$\downarrow$ rheobase''', fontsize=lfsize) ax3.text(-0.95, -0.55, 'GOF/\nLOF?', ha='right')
ax3_BL = ax3.inset_axes([0, 0, 0.3, 0.2]) ax3_BL = ax3.inset_axes([0.07, 0.15, 0.3, 0.2])
plot_diff_sqrt(ax3_BL, b2=0.1, c2=75) plot_diff_sqrt(ax3_BL, b2=0.07, c2=65)
ax3_BL.set_ylim(inset_ylim) ax3_BL.set_ylim(inset_ylim)
# bottom right # bottom right
ax3.text(x=0.25, y=-0.35, s=r'''$\downarrow$ AUC ax3.text(x=0.22, y=-0.95, s='$\\downarrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize)
$\uparrow$ rheobase''', fontsize=lfsize) ax3.text(0.95, -0.55, 'LOF')
ax3_BR = ax3.inset_axes([0.7, 0, 0.3, 0.2]) ax3_BR = ax3.inset_axes([0.63, 0.15, 0.3, 0.2])
plot_diff_sqrt(ax3_BR, b2=0.4, c2=75) plot_diff_sqrt(ax3_BR, b2=0.4, c2=60)
ax3_BR.set_ylim(inset_ylim) ax3_BR.set_ylim(inset_ylim)
# fig.savefig('./Figures/firing_characterization.pdf', bbox_inches='tight')
print(fig.dpi)
fig.set_size_inches(cm2inch(8.17,15))
fig.savefig('./Figures/firing_characterization.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi import matplotlib.lines as mlines
wt = mlines.Line2D([], [], color=colorslist[9], linestyle='-',label='WT')
mut = mlines.Line2D([], [], color=colorslist[2], linestyle='-',label='Altered')
pos = (0.575, 0.05)
ncol = 2
fig.legend(handles=[wt, mut], loc='center', bbox_to_anchor=pos, ncol=ncol, frameon=False, fontsize=8)
fig.set_size_inches(cm2inch(8.5,12))
fig.savefig('./Figures/firing_characterization.pdf', dpi=fig.dpi)
plt.show() plt.show()
#%% OLD #%% with arrows
# fig = plt.figure() fig = plt.figure(figsize=cm2inch(7, 12))
# # fig, axs = plt.subplots(2, 3, figsize=(6, 4)) gs = gridspec.GridSpec(3,6, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6)
# # fig.subplots_adjust(top=0.95, bottom=0.1, left=0.1, right=0.95, hspace=0.6, wspace=0.6) ax1 = fig.add_subplot(gs[0,1:])
# gs = gridspec.GridSpec(2,3, top=0.95, bottom=0.1, left=0.1, right = 0.95, hspace=0.6, wspace=0.6) show_spines(ax1, 'lb')
# ax1 = fig.add_subplot(gs[0,0]) plot_AUC(ax1, width=0.2)
# plot_AUC(ax1, width=0.2) ax3 = fig.add_subplot(gs[1:, :])
# ax2 = fig.add_subplot(gs[1, 0])
# ax3 = fig.add_subplot(gs[:, 1:]) # add panel letter labels
# # ax_list = fig.axes ax1.text(-0.4, 1.2, string.ascii_uppercase[0], transform=ax1.transAxes, size=16, weight='bold')
# # import string ax3.text(-0.15, 1.05, string.ascii_uppercase[1], transform=ax3.transAxes, size=16, weight='bold')
# # i =0
# # for a in ax_list: show_spines(ax3, '')
# # a.text(-0.13, 1.05, string.ascii_uppercase[i], transform=a.transAxes,size=12, weight='bold') plot_quadrant(ax3) # plot delineation into quadrants
# # i += 1
# ax3.set_ylabel('$\Delta$ AUC')
# ax3.set_xlabel('$\Delta$ rheobase') inset_ylim = (0, 100)
# ax3.set_xlim(-1,1) # top left
# ax3.set_ylim(-1,1) lfsize = 8
# plot_quadrant(ax3) ax3.text(x=-0.9, y=0.7, s='$\\uparrow$ AUC\n$\\downarrow$ rheobase', fontsize=lfsize)
# ax3.text(-0.95, 0.35, 'GOF', ha='right')
# # top left ax3_TL = ax3.inset_axes([0.07, 0.6, 0.3, 0.2])
# ax3.text(x=-0.75, y=0.25, s=r'''$\uparrow$ AUC plot_diff_sqrt(ax3_TL, b2=0.09, c2=200)
# $\downarrow$ rheobase''') ax3_TL.set_ylim(inset_ylim)
# ax3_TL = ax3.inset_axes([0,0.8,0.3,0.2]) ax3_TL.annotate('', (0.25, 7), (0.085, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
# plot_diff_sqrt(ax3_TL, b2=0.1, c2=200) ax3_TL.annotate('', (0.55, 55), (0.3, 90), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
# # top right
# # top right ax3.text(x=0.22, y=0.7, s='$\\uparrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize)
# ax3.text(x=0.25, y=0.25, s=r'''$\uparrow$ AUC ax3.text(0.95, 0.35, 'LOF/\nGOF?')
# $\uparrow$ rheobase''') ax3_TR = ax3.inset_axes([0.63, 0.6, 0.3, 0.2])
# ax3_TR = ax3.inset_axes([0.7, 0.8, 0.3, 0.2]) plot_diff_sqrt(ax3_TR, b2=0.4, c2=200)
# plot_diff_sqrt(ax3_TR, b2=0.4, c2=200) ax3_TR.set_ylim(inset_ylim)
# ax3_TR.annotate('', (0.17, 7), (0.41, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
# # bottom left ax3_TR.annotate('', (0.8, 70), (0.6, 90), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
# ax3.text(x=-0.75, y=-0.35, s=r'''$\downarrow$ AUC
# $\downarrow$ rheobase''') # bottom left
# ax3_BL = ax3.inset_axes([0, 0, 0.3, 0.2]) ax3.text(x=-0.9, y=-0.95, s='$\\downarrow$ AUC\n$\downarrow$ rheobase', fontsize=lfsize)
# plot_diff_sqrt(ax3_BL, b2=0.1, c2=75) ax3.text(-0.95, -0.55, 'GOF/\nLOF?', ha='right')
# ax3_BL = ax3.inset_axes([0.07, 0.15, 0.3, 0.2])
# # bottom right plot_diff_sqrt(ax3_BL, b2=0.06, c2=65)
# ax3.text(x=0.25, y=-0.35, s=r'''$\downarrow$ AUC ax3_BL.set_ylim(inset_ylim)
# $\uparrow$ rheobase''') ax3_BL.annotate('', (0.25, 7), (0.07, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
# ax3_BR = ax3.inset_axes([0.7, 0, 0.3, 0.2]) ax3_BL.annotate('', (0.8, 80), (0.85, 55), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
# plot_diff_sqrt(ax3_BR, b2=0.4, c2=75)
# # bottom right
# # ax3_TL.sharey(ax3_TR) ax3.text(x=0.22, y=-0.95, s='$\\downarrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize)
# ax3.text(0.95, -0.55, 'LOF')
# # ax3_TL.get_shared_x_axes().join(ax3_TL, ax3_TR, ax3_BL, ax3_BR) ax3_BR = ax3.inset_axes([0.63, 0.15, 0.3, 0.2])
# # ax3_TL.get_shared_y_axes().join(ax3_TL, ax3_TR, ax3_BL, ax3_BR) plot_diff_sqrt(ax3_BR, b2=0.4, c2=60)
# ax_list = [ax3_TL, ax3_TR, ax3_BL, ax3_BR] #< your axes objects ax3_BR.set_ylim(inset_ylim)
# ax_list[0].get_shared_x_axes().join(*ax_list) ax3_BR.annotate('', (0.18, 7), (0.42, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
# plt.show() ax3_BR.annotate('', (0.7, 75), (0.8, 37.5), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) #
#
# # plot_sqrt(axs[0,0])
# # plot_temperature(axs[0,1])
# # plot_signal_n_power(axs[1,0], axs[1,1]) fig.set_size_inches(cm2inch(8.5,12))
# # fig.savefig('coolresult.pdf') fig.savefig('./Figures/firing_characterization_arrows.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi
# plt.show()

View File

@ -0,0 +1,182 @@
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import string
# from plotstyle import plot_style
from plotstyle import scheme_style
def cm2inch(*tupl):
inch = 2.54
if isinstance(tupl[0], tuple):
return tuple(i/inch for i in tupl[0])
else:
return tuple(i/inch for i in tupl)
def plot_sqrt(ax, a=1, b=0.2, c=100, d=0):
x = np.linspace(0, 1, 10000)
y = c*np.sqrt(a*(x - b)) + d
ax.plot(x, y)
ax.set_xlabel('Current [nA]')
ax.set_ylabel('Frequency [Hz]')
ax.set_xlim(0,1)
ax.set_ylim(0, ax.get_ylim()[1])
def plot_AUC(ax, a=1, b=0.2, c=100, d=0, width=0.2):
x = np.linspace(0, 1, 10000)
y = c*np.sqrt(a*(x - b)) + d
ax.plot(x, y, 'k')
ax.set_xlabel('Current [nA]')
ax.set_ylabel('Frequency [Hz]')
ax.fill_between(x,y, where=(x<=b+width), color='c')
ax.set_xlim(0,1)
ax.set_ylim(0, 100)
ax.yaxis.set_major_locator(ticker.MultipleLocator(50))
def plot_diff_sqrt(ax, a=1, b=0.2, c=100, d=0, a2=1, b2=0.2, c2=100, d2=0):
x = np.linspace(0, 1, 10000)
y = c*np.sqrt(a*(x - b)) + d
y2 = c2 * np.sqrt(a2 * (x - b2)) + d2
ax.plot(x, y, 'k')
ax.plot(x, y2, 'b')
ax.set_xlim(0,1)
ax.set_ylim(0, ax.get_ylim()[1])
ax.set_xticks([])
ax.set_yticks([])
def plot_quadrant(ax):
ax.plot(ax.get_xlim(),[0,0], '--k', linewidth=1.25)
ax.plot([0,0],ax.get_ylim(), '--k', linewidth=1.25)
ax.tick_params(axis=u'both', which=u'both', length=0)
ax.set_xticks([-0.55, 0, 0.55])
a = ax.get_xticks().tolist()
a[0] = '\u2212'
a[1] = 0
a[2] = '+'
ax.set_xticklabels(a)
ax.set_yticks([-0.55, 0, 0.55])
b = ax.get_xticks().tolist()
b[0] = '\u2212'
b[1] = 0
b[2] = '+'
ax.set_yticklabels(b)
# ax.tick_params(labelsize=16)
# ax.set_yticks([0])
# ax.axis('off')
# plot_style()
scheme_style()
fig = plt.figure(figsize=cm2inch(7, 12))
gs = gridspec.GridSpec(3,2, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6)
ax1 = fig.add_subplot(gs[0,:])
plot_AUC(ax1, width=0.2)
ax3 = fig.add_subplot(gs[1:, :])
# add panel letter labels
ax_list = fig.axes
i =0
for a in ax_list:
a.text(-0.18, 1.08, string.ascii_uppercase[i], transform=a.transAxes,size=16, weight='bold')
i += 1
ax3.set_ylabel('$\Delta$ AUC')
ax3.set_xlabel('$\Delta$ rheobase')
ax3.set_xlim(-1, 1)
ax3.set_ylim(-1, 1)
plot_quadrant(ax3) # plot delineation into quadrants
inset_ylim = (0, 100)
# top left
lfsize = 8
ax3.text(x=-0.75, y=0.25, s=r'''$\uparrow$ AUC
$\downarrow$ rheobase''', fontsize=lfsize)
ax3_TL = ax3.inset_axes([0, 0.8, 0.3, 0.2])
plot_diff_sqrt(ax3_TL, b2=0.1, c2=200)
ax3_TL.set_ylim(inset_ylim)
# top right
ax3.text(x=0.25, y=0.25, s=r'''$\uparrow$ AUC
$\uparrow$ rheobase''', fontsize=lfsize)
ax3_TR = ax3.inset_axes([0.7, 0.8, 0.3, 0.2])
plot_diff_sqrt(ax3_TR, b2=0.4, c2=200)
ax3_TR.set_ylim(inset_ylim)
# bottom left
ax3.text(x=-0.75, y=-0.35, s=r'''$\downarrow$ AUC
$\downarrow$ rheobase''', fontsize=lfsize)
ax3_BL = ax3.inset_axes([0, 0, 0.3, 0.2])
plot_diff_sqrt(ax3_BL, b2=0.1, c2=75)
ax3_BL.set_ylim(inset_ylim)
# bottom right
ax3.text(x=0.25, y=-0.35, s=r'''$\downarrow$ AUC
$\uparrow$ rheobase''', fontsize=lfsize)
ax3_BR = ax3.inset_axes([0.7, 0, 0.3, 0.2])
plot_diff_sqrt(ax3_BR, b2=0.4, c2=75)
ax3_BR.set_ylim(inset_ylim)
# fig.savefig('./Figures/firing_characterization.pdf', bbox_inches='tight')
print(fig.dpi)
fig.set_size_inches(cm2inch(8.17,15))
fig.savefig('./Figures/firing_characterization_old.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi
plt.show()
#%% OLD
# fig = plt.figure()
# # fig, axs = plt.subplots(2, 3, figsize=(6, 4))
# # fig.subplots_adjust(top=0.95, bottom=0.1, left=0.1, right=0.95, hspace=0.6, wspace=0.6)
# gs = gridspec.GridSpec(2,3, top=0.95, bottom=0.1, left=0.1, right = 0.95, hspace=0.6, wspace=0.6)
# ax1 = fig.add_subplot(gs[0,0])
# plot_AUC(ax1, width=0.2)
# ax2 = fig.add_subplot(gs[1, 0])
# ax3 = fig.add_subplot(gs[:, 1:])
# # ax_list = fig.axes
# # import string
# # i =0
# # for a in ax_list:
# # a.text(-0.13, 1.05, string.ascii_uppercase[i], transform=a.transAxes,size=12, weight='bold')
# # i += 1
# ax3.set_ylabel('$\Delta$ AUC')
# ax3.set_xlabel('$\Delta$ rheobase')
# ax3.set_xlim(-1,1)
# ax3.set_ylim(-1,1)
# plot_quadrant(ax3)
#
# # top left
# ax3.text(x=-0.75, y=0.25, s=r'''$\uparrow$ AUC
# $\downarrow$ rheobase''')
# ax3_TL = ax3.inset_axes([0,0.8,0.3,0.2])
# plot_diff_sqrt(ax3_TL, b2=0.1, c2=200)
#
# # top right
# ax3.text(x=0.25, y=0.25, s=r'''$\uparrow$ AUC
# $\uparrow$ rheobase''')
# ax3_TR = ax3.inset_axes([0.7, 0.8, 0.3, 0.2])
# plot_diff_sqrt(ax3_TR, b2=0.4, c2=200)
#
# # bottom left
# ax3.text(x=-0.75, y=-0.35, s=r'''$\downarrow$ AUC
# $\downarrow$ rheobase''')
# ax3_BL = ax3.inset_axes([0, 0, 0.3, 0.2])
# plot_diff_sqrt(ax3_BL, b2=0.1, c2=75)
#
# # bottom right
# ax3.text(x=0.25, y=-0.35, s=r'''$\downarrow$ AUC
# $\uparrow$ rheobase''')
# ax3_BR = ax3.inset_axes([0.7, 0, 0.3, 0.2])
# plot_diff_sqrt(ax3_BR, b2=0.4, c2=75)
#
# # ax3_TL.sharey(ax3_TR)
#
# # ax3_TL.get_shared_x_axes().join(ax3_TL, ax3_TR, ax3_BL, ax3_BR)
# # ax3_TL.get_shared_y_axes().join(ax3_TL, ax3_TR, ax3_BL, ax3_BR)
# ax_list = [ax3_TL, ax3_TR, ax3_BL, ax3_BR] #< your axes objects
# ax_list[0].get_shared_x_axes().join(*ax_list)
# plt.show()
#
# # plot_sqrt(axs[0,0])
# # plot_temperature(axs[0,1])
# # plot_signal_n_power(axs[1,0], axs[1,1])
# # fig.savefig('coolresult.pdf')
#

View File

@ -253,17 +253,14 @@ def plot_I_ramp(ax):
I_ramp = np.zeros((stim_time, 1)) @ I_amp I_ramp = np.zeros((stim_time, 1)) @ I_amp
I_ramp[:, :] = np.ones((stim_time, 1)) @ I_amp I_ramp[:, :] = np.ones((stim_time, 1)) @ I_amp
stim_num_step = I_ramp.shape[1] stim_num_step = I_ramp.shape[1]
# start = np.int(initial_period * 1 / dt)
start=0 start=0
I_ramp[start:int(start + ramp_len), 0] = np.linspace(0, I_high, ramp_len) I_ramp[start:int(start + ramp_len), 0] = np.linspace(0, I_high, ramp_len)
I_ramp[int(start + ramp_len):int(start + ramp_len * 2), 0] = np.linspace(I_high, 0, ramp_len) I_ramp[int(start + ramp_len):int(start + ramp_len * 2), 0] = np.linspace(I_high, 0, ramp_len)
t = np.arange(0, 4000 * 2, dt) t = np.arange(0, 4000 * 2, dt)
ax.plot(t, I_ramp) ax.plot(t, I_ramp)
# ax.plot(model_ramp['t'], model_ramp[model], 'k', linewidth=0.0025)
ax.set_ylabel('I') ax.set_ylabel('I')
ax.set_xlabel('Time [s]') ax.set_xlabel('Time [s]')
# ax.set_ylim(-80, 60)
ax.axis('off') ax.axis('off')
ax.set_title('Ramp Current', fontsize=8, x=0.5, y=-0.5) ax.set_title('Ramp Current', fontsize=8, x=0.5, y=-0.5)
return ax return ax
@ -273,7 +270,6 @@ fig = plt.figure(figsize=cm2inch(17.6,25))
gs0 = fig.add_gridspec(2, 1, wspace=0.) gs0 = fig.add_gridspec(2, 1, wspace=0.)
gs00 = gs0[:].subgridspec(13, 1, wspace=0.7, hspace=1.0) gs00 = gs0[:].subgridspec(13, 1, wspace=0.7, hspace=1.0)
# gs01 = gs0[1:].subgridspec(7, 2, wspace=0.6, hspace=1)
ax1_ramp = fig.add_subplot(gs00[0]) ax1_ramp = fig.add_subplot(gs00[0])
ax2_ramp = fig.add_subplot(gs00[1]) ax2_ramp = fig.add_subplot(gs00[1])
@ -308,9 +304,7 @@ plt.rcParams.update({'font.size': 6})
add_scalebar(ax12_ramp, matchx=False, matchy=False, hidex=True, hidey=True, sizex=1000, sizey=50, labelx='1 s', add_scalebar(ax12_ramp, matchx=False, matchy=False, hidex=True, hidey=True, sizex=1000, sizey=50, labelx='1 s',
labely='50 mV', loc=3, pad=-2, borderpad=0, barwidth=1, bbox_to_anchor=Bbox.from_bounds(0.01, 0.05, 1, 1), labely='50 mV', loc=3, pad=-2, borderpad=0, barwidth=1, bbox_to_anchor=Bbox.from_bounds(0.01, 0.05, 1, 1),
bbox_transform=ax12_ramp.transAxes) bbox_transform=ax12_ramp.transAxes)
# add_scalebar(ax12_ramp, matchx=False, matchy=False, hidex=True, hidey=True, sizex=1000, sizey=25, labelx='1 s',
# labely='25 mV', loc=3, pad=-2, borderpad=0, barwidth=2, bbox_to_anchor=Bbox.from_bounds(-0.05, 0.1, 1, 1),
# bbox_transform=ax12_ramp.transAxes)
ax13_I = plot_I_ramp(ax13_I) ax13_I = plot_I_ramp(ax13_I)
add_scalebar(ax13_I, matchx=False, matchy=False, hidex=True, hidey=True, sizex=1000, sizey=0.0005, labelx='1 s', add_scalebar(ax13_I, matchx=False, matchy=False, hidex=True, hidey=True, sizex=1000, sizey=0.0005, labelx='1 s',
labely='0.5 $I_{max}$', loc=3, pad=-2, borderpad=0, barwidth=1, labely='0.5 $I_{max}$', loc=3, pad=-2, borderpad=0, barwidth=1,
@ -320,9 +314,8 @@ add_scalebar(ax13_I, matchx=False, matchy=False, hidex=True, hidey=True, sizex=1
for i in range(0,len(models)): for i in range(0,len(models)):
ramp_axs[i].text(-0.01, 1.1, string.ascii_uppercase[i], transform=ramp_axs[i].transAxes, size=10, weight='bold') ramp_axs[i].text(-0.01, 1.1, string.ascii_uppercase[i], transform=ramp_axs[i].transAxes, size=10, weight='bold')
# fig.savefig('./Figures/ramp_firing.pdf') #, bbox_inches='tight' #save
print(fig.dpi)
fig.set_size_inches(cm2inch(17.6,22)) fig.set_size_inches(cm2inch(17.6,22))
fig.savefig('./Figures/ramp_firing.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi fig.savefig('./Figures/ramp_firing.pdf', dpi=fig.dpi)
plt.show() plt.show()

View File

@ -94,14 +94,11 @@ def new_scatter(self, *args, **kwargs):
return FinalCollection return FinalCollection
Axes.scatter = new_scatter Axes.scatter = new_scatter
############## End hack. ############## ############## End hack. ##############
######################################################################################################################## ########################################################################################################################
#%% #%%
def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2): def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2):
# size =4
hlinewidth = 0.5 hlinewidth = 0.5
# ax.tick_params(axis='x', rotation=90)
model_names = ['RS pyramidal','RS inhibitory','FS', model_names = ['RS pyramidal','RS inhibitory','FS',
'RS pyramidal +$K_V1.1$','RS inhibitory +$K_V1.1$', 'RS pyramidal +$K_V1.1$','RS inhibitory +$K_V1.1$',
'FS +$K_V1.1$','Cb stellate','Cb stellate +$K_V1.1$', 'FS +$K_V1.1$','Cb stellate','Cb stellate +$K_V1.1$',
@ -123,7 +120,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2):
] ]
import matplotlib.colors import matplotlib.colors
colors = [matplotlib.colors.to_rgb(c) for c in colorslist] # sns.color_palette("hls", 14, desat=0.75)#[cm.tab20(i) for i in range(20)] colors = [matplotlib.colors.to_rgb(c) for c in colorslist]
clr_dict = {} clr_dict = {}
for m in range(len(model_names)): for m in range(len(model_names)):
clr_dict[model_names[m]] = colors[m] clr_dict[model_names[m]] = colors[m]
@ -132,7 +129,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2):
i = 3 # Kv1.1 act i = 3 # Kv1.1 act
ax.axvspan(i - 0.4, i + 0.4, fill=False, edgecolor='k') ax.axvspan(i - 0.4, i + 0.4, fill=False, edgecolor='k')
df = pd.read_csv('./Figures/Data/rheo_shift_corr.csv') df = pd.read_csv('./Figures/Data/rheo_shift_corr.csv')
sns.swarmplot(y="corr", x="$\Delta V_{1/2}$", hue="model", data=df, #dodge=True, sns.swarmplot(y="corr", x="$\Delta V_{1/2}$", hue="model", data=df,
palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize,
order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation', order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation',
'$K_V1.1$ inactivation', 'A activation', 'A inactivation'], '$K_V1.1$ inactivation', 'A activation', 'A inactivation'],
@ -150,7 +147,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2):
df = pd.read_csv('./Figures/Data/rheo_scale_corr.csv') df = pd.read_csv('./Figures/Data/rheo_scale_corr.csv')
# Add in points to show each observation # Add in points to show each observation
sns.swarmplot(y="corr", x="Slope (k)", hue="model", data=df, #dodge=True, sns.swarmplot(y="corr", x="Slope (k)", hue="model", data=df,
palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize,
order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation', order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation',
'$K_V1.1$ inactivation', 'A activation', 'A inactivation'], '$K_V1.1$ inactivation', 'A activation', 'A inactivation'],
@ -168,7 +165,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2):
df = pd.read_csv('./Figures/Data/rheo_g_corr.csv') df = pd.read_csv('./Figures/Data/rheo_g_corr.csv')
# Add in points to show each observation # Add in points to show each observation
sns.swarmplot(y="corr", x="g", hue="model", data=df, #dodge=True, sns.swarmplot(y="corr", x="g", hue="model", data=df,
palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize,
order=['Na', 'K', '$K_V1.1$', 'A', 'Leak'], order=['Na', 'K', '$K_V1.1$', 'A', 'Leak'],
hue_order=model_names, co2mk=Markers) hue_order=model_names, co2mk=Markers)
@ -184,7 +181,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2):
ax.xaxis.grid(False) ax.xaxis.grid(False)
sns.despine(trim=True, bottom=True, ax=ax) sns.despine(trim=True, bottom=True, ax=ax)
ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$') ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$')
# ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels())
def model_legend(ax, marker_s_leg, pos, ncol): def model_legend(ax, marker_s_leg, pos, ncol):
colorslist = [ '#40A787', # cyan'# colorslist = [ '#40A787', # cyan'#
@ -201,16 +198,13 @@ def model_legend(ax, marker_s_leg, pos, ncol):
'#D03050' # pink '#D03050' # pink
] ]
import matplotlib.colors import matplotlib.colors
colors = [matplotlib.colors.to_rgb(c) for c in colorslist] #sns.color_palette("hls", 14, desat=0.75) #[cm.tab20(i) for i in range(20)] colors = [matplotlib.colors.to_rgb(c) for c in colorslist]
model_pos = {'Cb stellate':0, 'RS Inhibitory':1, 'FS':2, 'RS Pyramidal':3, model_pos = {'Cb stellate':0, 'RS Inhibitory':1, 'FS':2, 'RS Pyramidal':3,
'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':4, 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':4,
'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':5, 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':6, 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':5, 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':6,
'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':7, 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':8, 'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':7, 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':8,
'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':9, 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':9,
'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':10, 'STN':11} 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':10, 'STN':11}
Markers = ["o", "o", "o", "^", "^", "^", "D", "D", "D", "s", "s", "s"] Markers = ["o", "o", "o", "^", "^", "^", "D", "D", "D", "s", "s", "s"]
RS_p = mlines.Line2D([], [], color=colors[model_pos['RS Pyramidal']], marker=Markers[model_pos['RS Pyramidal']], markersize=marker_s_leg, linestyle='None', RS_p = mlines.Line2D([], [], color=colors[model_pos['RS Pyramidal']], marker=Markers[model_pos['RS Pyramidal']], markersize=marker_s_leg, linestyle='None',
label='RS pyramidal') label='RS pyramidal')
@ -236,7 +230,6 @@ def model_legend(ax, marker_s_leg, pos, ncol):
ax.legend(handles=[RS_p, RS_i, FS, RS_p_Kv, RS_i_Kv, FS_Kv, Cb, Cb_pl, Cb_sw, STN, STN_pl, STN_sw], loc='center', ax.legend(handles=[RS_p, RS_i, FS, RS_p_Kv, RS_i_Kv, FS_Kv, Cb, Cb_pl, Cb_sw, STN, STN_pl, STN_sw], loc='center',
bbox_to_anchor=pos, ncol=ncol, frameon=False) bbox_to_anchor=pos, ncol=ncol, frameon=False)
def plot_rheo_alt(ax, model='FS', color1='red', color2='dodgerblue', alteration='shift'): def plot_rheo_alt(ax, model='FS', color1='red', color2='dodgerblue', alteration='shift'):
ax.spines["right"].set_visible(False) ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False) ax.spines["top"].set_visible(False)
@ -273,8 +266,7 @@ def plot_rheo_alt(ax, model='FS', color1='red', color2='dodgerblue', alteration=
'#873770', # magenta '#873770', # magenta
] ]
import matplotlib.colors import matplotlib.colors
colors = [matplotlib.colors.to_rgb(c) for c in colors = [matplotlib.colors.to_rgb(c) for c in colorslist]
colorslist] #sns.color_palette("hls", 14, desat=0.75)#[cm.tab20(i) for i in range(20)]
clr_dict = {} clr_dict = {}
for m in range(len(model_names)): for m in range(len(model_names)):
clr_dict[model_names[m]] = colors[m] clr_dict[model_names[m]] = colors[m]
@ -373,9 +365,7 @@ pad_w = 1.1
pad_h = 0.7 pad_h = 0.7
fig = plt.figure() fig = plt.figure()
# fig = plt.figure(figsize=cm2inch(17.6,10))
gs = fig.add_gridspec(3, 7, wspace=1.2, hspace=1.) gs = fig.add_gridspec(3, 7, wspace=1.2, hspace=1.)
# plt.subplots_adjust(hspace=0.8) #, wspace=0.6
ax0 = fig.add_subplot(gs[0,2:7]) ax0 = fig.add_subplot(gs[0,2:7])
ax0_ex = fig.add_subplot(gs[0,1]) ax0_ex = fig.add_subplot(gs[0,1])
ax0_fI = fig.add_subplot(gs[0,0]) ax0_fI = fig.add_subplot(gs[0,0])
@ -433,69 +423,6 @@ ax2_ex.text(-0.8, 1.35, string.ascii_uppercase[7], transform=ax2_ex.transAxes, s
ax2.text(-0.075, 1.35, string.ascii_uppercase[8], transform=ax2.transAxes, size=10, weight='bold') ax2.text(-0.075, 1.35, string.ascii_uppercase[8], transform=ax2.transAxes, size=10, weight='bold')
# save # save
# fig.savefig('./Figures/rheobase_correlation.pdf', bbox_inches='tight')
print(fig.dpi)
fig.set_size_inches(cm2inch(20.75,12)) fig.set_size_inches(cm2inch(20.75,12))
fig.savefig('./Figures/rheobase_correlation.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi fig.savefig('./Figures/rheobase_correlation.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi
plt.show() plt.show()
# #%% alternative layout
# marker_s_leg = 8
# max_width = 10
# pad_x = 0.2
# pad_y= 0.4
# pad_w = 0.22
# pad_h = 0.6
#
# fig = plt.figure(figsize=(12,20))
# gs = fig.add_gridspec(3, 1, hspace=0.4, wspace=0.4)
# gs0 = gs[0].subgridspec(2, 4, wspace=0.6, hspace=1.)
# gs1 = gs[1].subgridspec(2, 4, wspace=0.6, hspace=1.)
# gs2 = gs[2].subgridspec(2, 4, wspace=0.6, hspace=1.)
# ax0 = fig.add_subplot(gs0[1,:])
# ax0_ex = fig.add_subplot(gs0[0,2:])
# ax0_fI = fig.add_subplot(gs0[0,:2])
# ax1 = fig.add_subplot(gs1[1,:])
# ax1_ex = fig.add_subplot(gs1[0,2:])
# ax1_fI = fig.add_subplot(gs1[0,:2])
# ax2 = fig.add_subplot(gs2[1,:])
# ax2_ex = fig.add_subplot(gs2[0,2:])
# ax2_fI = fig.add_subplot(gs2[0,:2])
#
#
# ax0_fI = plot_fI(ax0_fI, model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', type='shift', alt='s', color1='lightgrey', color2='k')
# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax0_fI.transAxes, color=color_dict['FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'], alpha=1, zorder=-1)
# rec = ax0_fI.add_patch(rec)
# rec.set_clip_on(False)
#
# ax1_fI = plot_fI(ax1_fI, model='Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', type='slope', alt='u', color1='lightgrey', color2='k')
# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax1_fI.transAxes, color=color_dict['Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'], alpha=1, zorder=-1)
# rec = ax1_fI.add_patch(rec)
# rec.set_clip_on(False)
#
# ax2_fI = plot_fI(ax2_fI, model='Cb stellate', type='g', alt='Leak', color1='lightgrey', color2='k')
# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax2_fI.transAxes, color=color_dict['Cb stellate'], alpha=1, zorder=-1)
# rec = ax2_fI.add_patch(rec)
# rec.set_clip_on(False)
#
# # label subplots with letters
# ax0_fI.text(-0.2, 1.38, string.ascii_uppercase[0], transform=ax0_fI.transAxes, size=16, weight='bold') #-0.09
# ax1_fI.text(-0.2, 1.38, string.ascii_uppercase[1], transform=ax1_fI.transAxes,size=16, weight='bold')
# ax2_fI.text(-0.2, 1.38, string.ascii_uppercase[2], transform=ax2_fI.transAxes,size=16, weight='bold')
#
# # plot boxplots
# boxplot_with_markers(ax0,max_width, alteration='shift')
# boxplot_with_markers(ax1,max_width, alteration='slope')
# boxplot_with_markers(ax2,max_width, alteration='g')
# # plot legend
# pos = (0.5, -1.)
# ncol = 6
# model_legend(ax2, marker_s_leg, pos, ncol)
#
# # # plot rheo across model for example alteration
# plot_rheo_alt(ax0_ex,model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k', alteration='shift')
# plot_rheo_alt(ax1_ex,model='Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k',alteration='slope')
# plot_rheo_alt(ax2_ex, model='Cb stellate', color1='lightgrey', color2='k', alteration='g')
#
# fig.savefig('rheobase_correlation_2.pdf', bbox_inches='tight')
# plt.show()

View File

@ -3,7 +3,6 @@ import matplotlib.pyplot as plt
import pandas as pd import pandas as pd
import os import os
import string import string
# from plotstyle import plot_style
from Figures.plotstyle import sim_style from Figures.plotstyle import sim_style
import seaborn as sns import seaborn as sns
import scipy.stats as stats import scipy.stats as stats
@ -21,20 +20,17 @@ def Kendall_tau(df):
p = pd.DataFrame(columns=df.columns, index=df.columns) p = pd.DataFrame(columns=df.columns, index=df.columns)
for col in range((df.columns).shape[0]): for col in range((df.columns).shape[0]):
for col2 in range((df.columns).shape[0]): for col2 in range((df.columns).shape[0]):
# print(col, col2)
if col != col2: if col != col2:
_, p.loc[df.columns[col], df.columns[col2]] = stats.kendalltau( _, p.loc[df.columns[col], df.columns[col2]] = stats.kendalltau(
df[df.columns[col]], df[df.columns[col2]], nan_policy='omit') df[df.columns[col]], df[df.columns[col2]], nan_policy='omit')
return tau, p return tau, p
def correlation_plot(ax, df='AUC', title='', cbar=False): def correlation_plot(ax, df='AUC', title='', cbar=False):
# cbar_ax = fig.add_axes([0.94, .25, .03, .4])
cbar_ax = fig.add_axes([0.685, 0.44, .15, .01]) cbar_ax = fig.add_axes([0.685, 0.44, .15, .01])
cbar_ax.spines['left'].set_visible(False) cbar_ax.spines['left'].set_visible(False)
cbar_ax.spines['bottom'].set_visible(False) cbar_ax.spines['bottom'].set_visible(False)
cbar_ax.spines['right'].set_visible(False) cbar_ax.spines['right'].set_visible(False)
cbar_ax.spines['top'].set_visible(False) cbar_ax.spines['top'].set_visible(False)
# cbar_ax.axis('off')
cbar_ax.set_xticks([]) cbar_ax.set_xticks([])
cbar_ax.set_yticks([]) cbar_ax.set_yticks([])
if df == 'AUC': if df == 'AUC':
@ -102,7 +98,7 @@ def correlation_plot(ax, df='AUC', title='', cbar=False):
def mutation_plot(ax, model='RS_pramidal'): def mutation_plot(ax, model='RS_pramidal'):
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN', models = ['RS_pyramidal', 'RS_inhib', 'FS', 'Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN',
'STN_Kv', 'STN_Kv_only'] 'STN_Kv', 'STN_Kv_only']
model_names = ['RS pyramidal', 'RS inhibitory', 'FS', #'RS pyramidal', 'RS inhibitory', 'FS', 'IB', model_names = ['RS pyramidal', 'RS inhibitory', 'FS',
'Cb stellate', 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'Cb stellate', 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'STN', 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'] 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'STN', 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']
model_display_names = ['RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'Cb stellate', model_display_names = ['RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'Cb stellate',
@ -117,7 +113,6 @@ def mutation_plot(ax, model='RS_pramidal'):
ax_dict['RS_pyramidal'] = (0, 0) ax_dict['RS_pyramidal'] = (0, 0)
ax_dict['RS_inhib'] = (0, 1) ax_dict['RS_inhib'] = (0, 1)
ax_dict['FS'] = (1, 0) ax_dict['FS'] = (1, 0)
# ax_dict['IB'] = (1, 1)
ax_dict['Cb_stellate'] = (2, 0) ax_dict['Cb_stellate'] = (2, 0)
ax_dict['Cb_stellate_Kv'] = (2, 1) ax_dict['Cb_stellate_Kv'] = (2, 1)
ax_dict['Cb_stellate_Kv_only'] = (3, 0) ax_dict['Cb_stellate_Kv_only'] = (3, 0)
@ -129,7 +124,6 @@ def mutation_plot(ax, model='RS_pramidal'):
ylim_dict['RS_pyramidal'] = (-0.1, 0.3) ylim_dict['RS_pyramidal'] = (-0.1, 0.3)
ylim_dict['RS_inhib'] = (-0.6, 0.6) ylim_dict['RS_inhib'] = (-0.6, 0.6)
ylim_dict['FS'] = (-0.06, 0.08) ylim_dict['FS'] = (-0.06, 0.08)
# ylim_dict['IB'] = (-0.2, 0.2)
ylim_dict['Cb_stellate'] = (-0.1, 0.4) ylim_dict['Cb_stellate'] = (-0.1, 0.4)
ylim_dict['Cb_stellate_Kv'] = (-0.1, 0.5) ylim_dict['Cb_stellate_Kv'] = (-0.1, 0.5)
ylim_dict['Cb_stellate_Kv_only'] = (-1, 0.8) ylim_dict['Cb_stellate_Kv_only'] = (-1, 0.8)
@ -152,7 +146,7 @@ def mutation_plot(ax, model='RS_pramidal'):
mut_names = AUC.index mut_names = AUC.index
ax.plot(rheo.loc[mut_names, model_names[mod]]*1000, AUC.loc[mut_names, model_names[mod]], linestyle='', ax.plot(rheo.loc[mut_names, model_names[mod]]*1000, AUC.loc[mut_names, model_names[mod]], linestyle='',
markeredgecolor='grey', markerfacecolor='grey', marker=Marker_dict[model_display_names[mod]], markeredgecolor='grey', markerfacecolor='grey', marker=Marker_dict[model_display_names[mod]],
markersize=2) # markeredgecolor=clr_dict[model_names[mod]],markerfacecolor=clr_dict[model_names[mod]], markersize=2)
ax.plot(rheo.loc['wt', model_names[mod]], AUC.loc['wt', model_names[mod]], 'sk') ax.plot(rheo.loc['wt', model_names[mod]], AUC.loc['wt', model_names[mod]], 'sk')
@ -165,13 +159,12 @@ def mutation_plot(ax, model='RS_pramidal'):
markeredgecolor=mut_col[2], markerfacecolor=mut_col[2], marker=Marker_dict[model_display_names[mod]],markersize=4) markeredgecolor=mut_col[2], markerfacecolor=mut_col[2], marker=Marker_dict[model_display_names[mod]],markersize=4)
ax.plot(rheo.loc['V404I', model_names[mod]]*1000, AUC.loc['V404I', model_names[mod]], linestyle='', ax.plot(rheo.loc['V404I', model_names[mod]]*1000, AUC.loc['V404I', model_names[mod]], linestyle='',
markeredgecolor=mut_col[3], markerfacecolor=mut_col[5], marker=Marker_dict[model_display_names[mod]],markersize=4) markeredgecolor=mut_col[3], markerfacecolor=mut_col[5], marker=Marker_dict[model_display_names[mod]],markersize=4)
ax.set_title(model_display_names[mod], pad=14)#, color=clr_dict[models[mod]]) , fontsize=14 ax.set_title(model_display_names[mod], pad=14)
ax.set_xlabel('$\Delta$ Rheobase (pA)')#, fontsize=6) ax.set_xlabel('$\Delta$ Rheobase (pA)')
ax.set_ylabel('Normalized $\Delta$AUC')#, fontsize=6) ax.set_ylabel('Normalized $\Delta$AUC')
ax.spines['right'].set_visible(False) ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False) ax.spines['top'].set_visible(False)
# ax.ticklabel_format(style='scientific', useMathText=True, useOffset=False) ax.ticklabel_format(axis="y", style="sci", scilimits=(0, 0),useMathText=True)
ax.ticklabel_format(axis="y", style="sci", scilimits=(0, 0),useMathText=True) #,useOffset=False
xmin, xmax = ax.get_xlim() xmin, xmax = ax.get_xlim()
ymin, ymax = ax.get_ylim() ymin, ymax = ax.get_ylim()
@ -196,10 +189,9 @@ def mutation_legend(ax, marker_s_leg, pos, ncol):
# plot_style()
sim_style() sim_style()
# plot setup # plot setup
fig = plt.figure() #figsize=cm2inch(17.6,15) fig = plt.figure()
gs0 = fig.add_gridspec(1, 6, wspace=-0.2) gs0 = fig.add_gridspec(1, 6, wspace=-0.2)
gsl = gs0[0:3].subgridspec(3, 3, wspace=0.9, hspace=0.8) gsl = gs0[0:3].subgridspec(3, 3, wspace=0.9, hspace=0.8)
gsr = gs0[4:6].subgridspec(6, 1, wspace=0.6, hspace=1) gsr = gs0[4:6].subgridspec(6, 1, wspace=0.6, hspace=1)
@ -247,9 +239,7 @@ axr0.text(-0.77, 1.1, string.ascii_uppercase[j], transform=axr0.transAxes, size=
axr1.text(-0.77, 1.1, string.ascii_uppercase[j+1], transform=axr1.transAxes, size=10, weight='bold') axr1.text(-0.77, 1.1, string.ascii_uppercase[j+1], transform=axr1.transAxes, size=10, weight='bold')
# save # save
# fig.savefig('./Figures/simulation_model_comparison.pdf') #, bbox_inches='tight'
print(fig.dpi)
fig.set_size_inches(cm2inch(22.2,15)) fig.set_size_inches(cm2inch(22.2,15))
fig.savefig('./Figures/simulation_model_comparison.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi fig.savefig('./Figures/simulation_model_comparison.pdf', dpi=fig.dpi)
plt.show() plt.show()