# -*- coding: utf-8 -*- """ Created on Sat Jul 3 19:52:04 2021 @author: nils """ import pandas as pd import numpy as np import string import textwrap import json import matplotlib import matplotlib.lines as mlines from matplotlib import ticker from matplotlib.ticker import NullFormatter from plotstyle import boxplot_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) #%% ##################### From https://stackoverflow.com/questions/52878845/swarmplot-with-hue-affecting-marker-beyond-color ## # to change marker types in seaborn swarmplot import seaborn as sns import matplotlib.pyplot as plt ############## Begin hack ############## from matplotlib.axes._axes import Axes from matplotlib.markers import MarkerStyle from numpy import ndarray def GetColor2Marker(markers): 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 ] import matplotlib.colors palette = [matplotlib.colors.to_rgb(c) for c in colorslist] mkcolors = [(palette[i]) for i in range(len(markers))] return dict(zip(mkcolors,markers)) def fixlegend(ax,markers,markersize=3,**kwargs): # Fix Legend legtitle = ax.get_legend().get_title().get_text() _,l = ax.get_legend_handles_labels() 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 ] import matplotlib.colors palette = [matplotlib.colors.to_rgb(c) for c in colorslist] mkcolors = [(palette[i]) for i in range(len(markers))] newHandles = [plt.Line2D([0],[0], ls="none", marker=m, color=c, mec="none", markersize=markersize,**kwargs) \ for m,c in zip(markers, mkcolors)] ax.legend(newHandles,l) leg = ax.get_legend() leg.set_title(legtitle) old_scatter = Axes.scatter def new_scatter(self, *args, **kwargs): colors = kwargs.get("c", None) co2mk = kwargs.pop("co2mk",None) FinalCollection = old_scatter(self, *args, **kwargs) if co2mk is not None and isinstance(colors, ndarray): Color2Marker = GetColor2Marker(co2mk) paths=[] for col in colors: mk=Color2Marker[tuple(col)] marker_obj = MarkerStyle(mk) paths.append(marker_obj.get_path().transformed(marker_obj.get_transform())) FinalCollection.set_paths(paths) return FinalCollection Axes.scatter = new_scatter ############## End hack. ############## ######################################################################################################################## #%% def boxplot_with_markers(ax,max_width, alteration='shift', msize=3): # size =4 # ax.tick_params(axis='x', rotation=90) model_names = ['RS pyramidal','RS inhibitory','FS', 'RS pyramidal +$K_V1.1$','RS inhibitory +$K_V1.1$', 'FS +$K_V1.1$','Cb stellate','Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$', 'STN $\Delta$$K_V1.1$'] colorslist = ['#007030', # dark green '#F0D730', # yellow '#C02717', # red '#478010', # green '#AAB71B', # lightgreen '#F78017', # orange '#40A787', # cyan'# '#008797', # light blue '#2060A7', # blue '#D03050', # pink '#53379B', # purple '#873770', # magenta ] # 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 # ] hlinewidth =0.5 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)] clr_dict = {} for m in range(len(model_names)): clr_dict[model_names[m]] = colors[m] Markers = ["o", "o", "o", "^", "^", "^", "D", "D", "D", "s", "s", "s"] if alteration=='shift': i = 2 # Kd act ax.axvspan(i - 0.4, i + 0.4, fill=False, edgecolor = 'k') df = pd.read_csv('./Figures/Data/AUC_shift_corr.csv') sns.swarmplot(y="corr", x="$\Delta V_{1/2}$", hue="model", data=df, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation', '$K_V1.1$ inactivation', 'A activation', 'A inactivation'], hue_order=model_names, co2mk=Markers) lim = ax.get_xlim() 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.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) elif alteration=='slope': i = 3 # Kv1.1 act ax.axvspan(i - 0.4, i + 0.4, fill=False, edgecolor='k') df = pd.read_csv('./Figures/Data/AUC_scale_corr.csv') # Add in points to show each observation sns.swarmplot(y="corr", x="Slope (k)", hue="model", data=df, #dodge=True, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation', '$K_V1.1$ inactivation', 'A activation', 'A inactivation'], hue_order=model_names, co2mk=Markers) 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]], [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) # sns.despine(trim=True, bottom=True, ax=ax) elif alteration=='g': i = 1 # Kd ax.axvspan(i - 0.4, i + 0.4, fill=False, edgecolor='k') df = pd.read_csv('./Figures/Data/AUC_g_corr.csv') # Add in points to show each observation sns.swarmplot(y="corr", x="g", hue="model", data=df, #dodge=True, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, order=['Na', 'K', '$K_V1.1$', 'A', 'Leak'], hue_order=model_names, co2mk=Markers) 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]], [1, 1], ':k',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth) # 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_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels()) else: print('Please chose "shift", "slope" or "g"') ax.get_legend().remove() ax.xaxis.grid(False) sns.despine(trim=True, bottom=True, ax=ax) 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): 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 ] 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)] model_pos = {'Cb stellate':0, 'RS Inhibitory':1, 'FS':2, 'RS Pyramidal':3, '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, '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, 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':10, 'STN':11} 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', label='RS pyramidal') RS_i = mlines.Line2D([], [], color=colors[model_pos['RS Inhibitory']], marker=Markers[model_pos['RS Inhibitory']], markersize=marker_s_leg, linestyle='None', label='RS inhibitory') FS = mlines.Line2D([], [], color=colors[model_pos['FS']], marker=Markers[model_pos['FS']], markersize=marker_s_leg, linestyle='None', label='FS') RS_p_Kv = mlines.Line2D([], [], color=colors[model_pos['RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], marker=Markers[model_pos['RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], markersize=marker_s_leg, linestyle='None', label='RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$') RS_i_Kv = mlines.Line2D([], [], color=colors[model_pos['RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], marker=Markers[model_pos['RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], markersize=marker_s_leg, linestyle='None', label='RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$') FS_Kv = mlines.Line2D([], [], color=colors[model_pos['Cb stellate']], marker=Markers[model_pos['Cb stellate']], markersize=marker_s_leg, linestyle='None', label='FS +$K_V1.1$') Cb = mlines.Line2D([], [], color=colors[8], marker=Markers[8], markersize=marker_s_leg, linestyle='None', label='Cb stellate') Cb_pl = mlines.Line2D([], [], color=colors[model_pos['Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], marker=Markers[model_pos['Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], markersize=marker_s_leg, linestyle='None', label='Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$') Cb_sw = mlines.Line2D([], [], color=colors[model_pos['Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], marker=Markers[model_pos['Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], markersize=marker_s_leg, linestyle='None', label='Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$') STN = mlines.Line2D([], [], color=colors[model_pos['STN']], marker=Markers[model_pos['STN']], markersize=marker_s_leg, linestyle='None', label='STN') STN_pl = mlines.Line2D([], [], color=colors[model_pos['STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], marker=Markers[model_pos['STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], markersize=marker_s_leg, linestyle='None', label='STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$') STN_sw = mlines.Line2D([], [], color=colors[model_pos['STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], marker=Markers[model_pos['STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']], markersize=marker_s_leg, linestyle='None', label='STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$') 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) def plot_AUC_alt(ax, model='FS', color1='red', color2='dodgerblue', alteration='shift'): ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) model_names = ['RS Pyramidal','RS Inhibitory','FS', 'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$','Cb stellate','Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$', 'STN $\Delta$$K_V1.1$'] model_name_dict = {'RS Pyramidal': 'RS Pyramidal', 'RS Inhibitory': 'RS Inhibitory', 'FS': 'FS', 'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'RS Pyramidal +$K_V1.1$', 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'RS Inhibitory +$K_V1.1$', 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'FS +$K_V1.1$', 'Cb stellate': 'Cb stellate', 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'Cb stellate $\Delta$$K_V1.1$', 'STN': 'STN', 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'STN +$K_V1.1$', 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'STN $\Delta$$K_V1.1$'} colorslist = ['#007030', # dark green '#F0D730', # yellow '#C02717', # red '#478010', # green '#AAB71B', # lightgreen '#F78017', # orange '#40A787', # cyan'# '#008797', # light blue '#2060A7', # blue '#D03050', # pink '#53379B', # purple '#873770', # magenta ] 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)] clr_dict = {} for m in range(len(model_names)): clr_dict[model_names[m]] = colors[m] if alteration=='shift': df = pd.read_csv('./Figures/Data/AUC_shift_ex.csv') df = df.sort_values('alteration') ax.set_xlabel('$\Delta$$V_{1/2}$') elif alteration=='slope': df = pd.read_csv('./Figures/Data/AUC_slope_ex.csv') ax.set_xscale("log") ax.set_xticks([0.5, 1, 2]) ax.xaxis.set_major_formatter(ticker.ScalarFormatter()) ax.xaxis.set_minor_formatter(NullFormatter()) ax.set_xlabel('Slope factor k') elif alteration=='g': df = pd.read_csv('./Figures/Data/AUC_g_ex.csv') ax.set_xscale("log") ax.set_xticks([0.5, 1, 2]) ax.xaxis.set_major_formatter(ticker.ScalarFormatter()) ax.xaxis.set_minor_formatter(NullFormatter()) ax.set_xlabel('g') for mod in model_names: if mod == model_name_dict[model]: ax.plot(df['alteration'], df[mod], color=clr_dict[mod], alpha=1, zorder=10, linewidth=2) else: ax.plot(df['alteration'], df[mod], color=clr_dict[mod],alpha=1, zorder=1, linewidth=1) ax.set_ylabel('Normalized AUC') x = df['alteration'] y = df[model_name_dict[model]] ax.set_xlim(x.min(), x.max()) ax.set_ylim(df[model_names].min().min(), df[model_names].max().max()) return ax def plot_fI(ax, model='RS Pyramidal', type='shift', alt='m', color1='red', color2='dodgerblue'): model_save_name = {'RS Pyramidal': 'RS_pyr_posp', 'RS Inhibitory': 'RS_inhib_posp', 'FS': 'FS_posp', 'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'RS_pyr_Kv', 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'RS_inhib_Kv', 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'FS_Kv', 'Cb stellate': 'Cb_stellate', 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'Cb_stellate_Kv', 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'Cb_stellate_Kv_only', 'STN': 'STN', 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'STN_Kv', 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'STN_Kv_only'} cvals = [-2., 2] colors = [color1, color2] norm = plt.Normalize(min(cvals), max(cvals)) tuples = list(zip(map(norm, cvals), colors)) cmap = matplotlib.colors.LinearSegmentedColormap.from_list("", tuples) colors = cmap(np.linspace(0, 1, 22)) df = pd.read_csv('./Figures/Data/Model_fI/{}_fI.csv'.format(model_save_name[model])) df.drop(['Unnamed: 0'], axis=1) newdf = df.loc[df.index[(df['alt'] == alt) & (df['type'] == type)], :] newdf['mag'] = newdf['mag'].astype('float') newdf = newdf.sort_values('mag').reset_index() c = 0 for i in newdf.index: ax.plot(json.loads(newdf.loc[i, 'I']), json.loads(newdf.loc[i, 'F']), color=colors[c]) c += 1 ax.set_ylabel('Frequency [Hz]') ax.set_xlabel('Current [nA]') ax.set_title(model) ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) L = ax.get_ylim() ax.set_ylim([0, L[1]]) return ax #%% boxplot_style() color_dict = {'Cb stellate': '#40A787', # cyan'# 'RS Inhibitory': '#F0D730', # yellow 'FS': '#C02717', # red 'RS Pyramidal': '#007030', # dark green 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': '#AAB71B', # lightgreen 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': '#008797', # light blue 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': '#F78017', # orange 'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': '#478010', # green 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': '#53379B', # purple 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': '#2060A7', # blue 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': '#873770', # magenta 'STN': '#D03050' # pink } # plot setup marker_s_leg = 2 max_width = 20 pad_x = 0.65 pad_y= 0.4 pad_w = 0.85 pad_h = 0.7 fig = plt.figure() # fig = plt.figure() # fig.set_size_inches(cm2inch(17.6,10)) gs = fig.add_gridspec(3, 6, wspace=1., hspace=0.8) # plt.subplots_adjust(hspace=0.8) #, wspace=0.6 ax0 = fig.add_subplot(gs[0,2:6]) ax0_ex = fig.add_subplot(gs[0,1]) ax0_fI = fig.add_subplot(gs[0,0]) ax1 = fig.add_subplot(gs[1,2:6]) ax1_ex = fig.add_subplot(gs[1,1]) ax1_fI = fig.add_subplot(gs[1,0]) ax2 = fig.add_subplot(gs[2,2:6]) ax2_ex = fig.add_subplot(gs[2,1]) ax2_fI = fig.add_subplot(gs[2,0]) line_width = 1 # plot fI examples 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=line_width,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=line_width,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=line_width,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.95, 1.12, string.ascii_uppercase[0], transform=ax0_fI.transAxes, size=10, weight='bold') #-0.09 ax1_fI.text(-0.95, 1.12, string.ascii_uppercase[1], transform=ax1_fI.transAxes,size=10, weight='bold') ax2_fI.text(-0.95, 1.12, string.ascii_uppercase[2], transform=ax2_fI.transAxes,size=10, 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.25, -0.6) ncol = 6 model_legend(ax2, marker_s_leg, pos, ncol) # plot examples plot_AUC_alt(ax0_ex,model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 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') #save # plt.tight_layout(pad=0) print(fig.dpi) fig.set_size_inches(cm2inch(21,10)) fig.savefig('./Figures/AUC_correlation.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi 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()