コード例 #1
0
ファイル: plotpitch.py プロジェクト: miaomaocat/chirp
def multiplotter(outfile, config, cout=None):
    """
    A coroutine for plotting a bunch of motifs on the same page. A
    useful entry point for scripts that want to do something similar
    to cplotpitch, but with control over which motifs get plotted.
    """
    matplotlib.use('PDF')
    from matplotlib.backends.backend_pdf import PdfPages as multipdf
    from matplotlib.pyplot import close as close_figure
    from ..version import version
    from ..common.graphics import axgriditer
    from ..common.signal import spectrogram

    def gridfun(**kwargs):
        from matplotlib.pyplot import subplots
        return subplots(_nrows,_ncols,sharex=True,sharey=True, figsize=_figsize)

    def figfun(fig):
        ax = fig.axes[0]
        ax.set_xticklabels('')
        ax.set_yticklabels('')
        fig.subplots_adjust(left=0.05, right=0.95, wspace=0)
        pp.savefig(fig)
        close_figure(fig)

    # set up plotting
    pp = multipdf(outfile)
    axg = axgriditer(gridfun, figfun)
    spectrogram = spectrogram(configfile=config)
    plt = plotter(configfile=config)

    filt = postfilter.pitchfilter(configfile=config)
    print >> cout, filt.options_str()

    try:
        # first call to yield won't return anything
        ax = None
        while 1:
            # receives filename from caller and returns last axes
            basename = yield ax
            ax = axg.next()
            print "** %s" % basename

            signal,Fs,t,p = load_data(basename, filt)
            spec,extent = spectrogram.dbspect(signal,Fs)
            plt.plot_spectrogram(ax, spec, extent)
            if t is not None:
                plt.plot_trace(ax, t,p)

        # loop will break when caller sends stop()
    finally:
        axg.close()
        pp.close()
コード例 #2
0
ファイル: multiplot.py プロジェクト: margoliashlab/dlab
 def __init__(self, filename):
     from matplotlib.backends.backend_pdf import PdfPages as multipdf
     """ Open a new PDF file for output with name @param filename """
     self.filename = filename
     self.handle = multipdf(filename)
コード例 #3
0
ファイル: multiplot.py プロジェクト: melizalab/dlab
 def __init__(self, filename):
     from matplotlib.backends.backend_pdf import PdfPages as multipdf
     """ Open a new PDF file for output with name @param filename """
     self.filename = filename
     self.handle = multipdf(filename)