def show_residuals_over_trials(self, graph=None, ax=None, threshold=100): if graph is None: from datavyz import ges as graph if ax is None: # fig, ax = graph.figure(axes=(1,3), wspace=.2, # left=.7, bottom=.7, figsize=(.7,1.)) fig, ax = graph.figure(left=.7, bottom=.7, figsize=(.7,1.)) else: fig = None result = self.result if self.new_result is not None: RESULTS = [self.result, self.new_result] else: RESULTS = [self.result] for res in RESULTS: indices = np.argsort(res['residuals']) x = res['residuals'][indices] full_x = np.concatenate([np.arange(1, len(indices)+1)[x<=threshold], [len(indices)+1, res['Ntot']]]) full_y = np.concatenate([x[x<=threshold], [threshold, threshold]]) ax.plot(np.log10(full_x), np.log10(full_y), clip_on=False) graph.set_plot(ax, # yticks=np.log10([1, 2, 5, 10, 20]), # yticks_labels=['1', '2', '5', '10', '>20'], # yminor_ticks=np.log10([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20]), # ylim=[1, np.log10(threshold)], xminor_ticks=np.log10(np.concatenate([[i*10**k for i in range(1,10)]\ for k in range(0,7)])), xlim=[np.log10(result['Ntot']), -1.], xticks=np.arange(7), xticks_labels=['1','','','$10^3$','','','$10^6$'], xlabel='config #', ylabel=r'fit $\chi^2$ (norm.) ', ylabelpad=-7) graph.annotate(ax, '4 pop. model', (.4, 1.2), ha='center') return fig, ax
# ge.title(AX[i], "a=%.2f, k=%.2f, $\gamma$=%.2f" % (residual.x[0], residual.x[1], residual.x[2]), color=getattr(ge, color), size='small') ge.title(AX[i], "k=%.2f, $\gamma$=%.2f" % (residual.x[0], residual.x[1]), color=getattr(ge, color), size='small') ge.scatter(lum, array, ax=AX[i], color=getattr(ge, color), label='data', ms=3) ge.plot(lum, func(lum, residual.x), ax=AX[i], lw=3, alpha=.5, color=getattr(ge, color), label='fit') ge.annotate(AX[i], '$\lambda$=%s' % LAMBDA[color], (0.5, .1), color=getattr(ge, color)) ge.set_plot(AX[i], xlabel='(computer) luminosity', xticks=[0, 0.5, 1], yticks=[0, 0.5, 1], ylabel='measured I (norm.)') fig.savefig('doc/gamma-correction-%s.png' % correc) ge.show()
fig1, ax, _ = matrix(ge, z, aspect='equal', xlabel='x-label (X)', ylabel='y-label (Y)') x, y, z = np.array(x).flatten(),\ np.array(y).flatten(),\ np.array(z).flatten()*np.random.randn(len(z.flatten())) index = (x < 15) & (y < x) # np.random.shuffle(index) x, y, z = x[index], y[index], z[index] fig2, ax, acb = twoD_plot(ge, x, y, z, vmin=-7, vmax=7, bar_legend_args={ 'label': 'color', 'ticks': [-7, 0, 7], 'ticks_labels': ['-7', '0', '>7'], 'color_discretization': 20 }) ge.set_plot(ax, xlabel='x-label (X)', ylabel='y-label (Y)') fig2.savefig('docs/surface-plot.png') ge.show()
from analyz.IO.npz import load_dict from datavyz import ges as ge data = load_dict('data.npz') fig, AX = ge.figure(axes=(1,3), figsize=(2.,1.)) ge.plot(data['t'], Y=[data['Vsoma'], data['Vdend']], LABELS=['soma', 'dend'], COLORS=['k', ge.blue], ax=AX[0], axes_args={'ylabel':'Vm (mV)', 'xlim':[0, data['t'][-1]]}) ge.plot(data['t'], Y=[data['Casoma'], data['Cadend']], COLORS=['k', ge.blue], ax=AX[1], axes_args={'ylabel':'[Ca$^{2+}$] (nM)', 'xlabel':'time (ms)', 'xlim':[0, data['t'][-1]]}) ge.scatter(data['Espike_times'], data['Espike_IDs'], color=ge.green,ax=AX[2],no_set=True,ms=3) ge.scatter(data['Ispike_times'], data['Espike_IDs'].max()*1.2+data['Ispike_IDs'], color=ge.red, ax=AX[2], no_set=True, ms=3) ge.set_plot(AX[2], [], xlim=[0, data['t'][-1]]) fig.savefig('/home/yann/Desktop/trace.svg') ge.show() else: nrn.defaultclock.dt = 0.025*nrn.ms # calcium dynamics following: HighVoltageActivationCalciumCurrent + LowThresholdCalciumCurrent # Equation_String = nrn.CalciumConcentrationDynamics(contributing_currents='0*mA/cm**2', Equation_String = nrn.CalciumConcentrationDynamics(contributing_currents='IHVACa+IT', name='CaDynamics').insert(nrn.Equation_String) # intrinsic currents CURRENTS = [nrn.PassiveCurrent(name='Pas'), nrn.PotassiumChannelCurrent(name='K'),
return data if __name__ == '__main__': import sys if len(sys.argv) > 1: fn = sys.argv[1] else: fn = '/home/yann/DATA/2020_09_11/13-40-10/pupil-data.npy' from datavyz import ges as ge data = np.load(fn, allow_pickle=True).item() fig, AX = ge.figure(axes=(1, 6), figsize=(3, 1), hspace=0.1) for i, key in enumerate(['cx', 'cy', 'sx', 'sy', 'residual']): AX[i].plot(data['times'], data[key], label='fit') data = replace_outliers(data) for i, key in enumerate(['cx', 'cy', 'sx', 'sy', 'residual']): AX[i].plot(data['times'], data[key + '-corrected'], label='corrected') ge.set_plot(AX[i], xlim=[data['times'][0], data['times'][-1]], ylabel=key) ge.show()
figsize=(.7, 1), right=4., hspace=0.1, bottom=0.1) ge.title(AX[0], '%i to %i synapses (by 2)' % (N_PULSES[0], N_PULSES[-1])) for synapses_loc, label, ax in zip([PROX, DIST], ['prox', 'dist'], AX): for i in range(len(data['v-%s' % label])): ax.plot(data['t'], data['v-%s' % label][i], label=label, color='k', lw=1) ge.set_plot(ax, [], ylim=[-76, -45], xlim=[0, tstop]) ge.draw_bar_scales(ax, Xbar=50., Xbar_label='50ms', Ybar=5., Ybar_label='5mV', loc='top-right') ge.show() else: from single_cell_sim import * if args.chelated_zinc: Model['Deltax0'] = 0. # removing Zinc modulation !! data = {'t': [], 'v-prox': [], 'v-dist': []}
# axes_args={'spines':['left', 'bottom'], 'xlabel':'my-x value', 'ylabel':'my-y value'}) # save_on_desktop(fig, figname='2.svg') # show() # mg = graphs('ggplot_npotebook') # mg = graphs() # mg.hist(np.random.randn(100), xlabel='ksjdfh') from datavyz import ges as ge # ge.boxplot(np.exp(np.random.randn(100)), # axes_args=dict(xticks=[1], # xticks_labels=['data'])) fig_lf, AX = ge.figure(axes_extents=[[[3, 1]], [[1, 2], [1, 2], [1, 2]]], figsize=(1., .5), wspace=3., hspace=2.) for ax in [item for sublist in AX for item in sublist]: ge.top_left_letter(ax, 'a') # _, ax, _ = ge.figure(with_bar_legend=True) AX[1][0].hist(np.random.randn(100)) fig, ax = ge.figure() ax.hist(np.random.randn(100)) ge.panel_label(ax, 'a') ge.annotate(ax, 'blabla', (0.7, 0.8), italic=True) ge.set_plot(ax) ge.show() ge.show()