xmin = min([x[0] for x in xlims])
    xmax = max([x[1] for x in xlims])
    for i,ax in enumerate(plt.gcf().axes):
        ax.set_xlim((xmin, xmax)) 
        ax.set_ylim(ylim)
        ax.legend()

        # add a scale bar
        if i==0:
            add_scalebar(ax, bbox_transform = ax.transAxes, **sb_kwds)
        else:
            # hide axis and spines
            ax.xaxis.set_visible(False)
            ax.yaxis.set_visible(False)            
            for loc, spine in ax.spines.iteritems():
                    spine.set_color('none')
            
    return plt.gcf()
    
if __name__=='__main__':
    # make list of dicts like so:
    files_dict = [{'abf':abf_reader('./2012_08_24_0000.abf'),
                   'color':'black',
                   'label':'control'},
                  {'abf':abf_reader('./2012_08_24_0004.abf'),
                   'color':'red',
                   'label':'frf'}]
    fig = main(files_dict)
    fig.set_size_inches(10,8)
    fig.savefig('default_fig_name.png', dpi = 300)
Example #2
0
        self.MsecLeadIn = MsecLeadIn
        super(waterfall_int_current, self).__init__(*args, **kwds)

    def gen_iter(self):
        for i, swp_idx in enumerate(self._swps):
            xs = self.xs + self.offset*i
            # have to get the lead in here
            lead_dp = int((self.MsecLeadIn / 1000.) * self.sr)
            Vm = self.abf_epoch._data(swp_idx,leadin_dp=lead_dp)[:,self.channo] + self.yoffset*i
            tarr = np.r_[0:len(Vm)/self.sr:self.xstep]
            current = self.CurrentSpecifier(Vm, tarr)
            ys = current[lead_dp:] + self.yoffset*i
            lvl = self.abf_epoch._lvl(swp_idx)
            yield xs, ys, lvl
        self.xlim = (0, max(xs))

if __name__=='__main__':
    ''' debug script '''
    import os
    labdir = os.environ.get("LABDIR")
    abfpath = os.path.join(labdir,
                 'B44_B48_experiments',
                 'b48_fI_summary',
                 'frf', '2012_08_24_0004.abf')
    abf = abf_reader(abfpath)
    epch = epoch(abf, 1, 1)
    epch.set_pading(left = 1000, right = 1000)
    for xs,ys,lvl in waterfall(epch, selectd = np.r_[0:18:2]):
        plt.plot(xs,ys, '-k', linewidth = 0.5)
    plt.show()
import os
from abf_reader import *
import matplotlib.pyplot as plt
from matt_axes_cust import xscale, yscale, clean_axes, no_spines
import pdb

########## load fixture data ##########
data_path = os.path.join(os.environ.get('LABDIR'),
                         'B44_B48_experiments','b48_fI_summary','control')
fI = abf_reader(os.path.join(data_path, '2012_09_08_0009.abf'))
########## end load fixture data ##########

#################### time steps and DACs #################### 
DAC_num = 1                       
ADC_num = 0
xstep = 1/sample_rate(fI.header)
sr = sample_rate(fI.header)
#################### end time steps and DACs ################

#################### PLOT fI ####################
for swp_num, swp in enumerate(make_swp_indxs(fI.header)):
    swp_len = swp[1]-swp[0]
    swp_x_offset = 1.4 * swp_num
    swp_y_offset = 0 * swp_num
    xs = np.r_[0:swp_len/sr:xstep] + swp_x_offset
    ys = fI.read_data()[slice(swp[0],swp[1]),0] + swp_y_offset
    # make sure xs arnt too long, with float fups
    xs = xs[0:len(ys)]
    plt.plot(xs,ys, linewidth = 0.3, color = 'black')
    xmax = np.max(xs)
ax = plt.gca()