コード例 #1
0
ファイル: imagefile.py プロジェクト: andrewmhammond/trtools
def save_images(dir='', figs=None, prefix=None):
    """
    Save all open figures to image files. 

    Parameters:
    ----------
    dir : string
        Directory to place image files into
    figs : list of Figures
        will default to open figures
    prefix : string
        prefix all image file names
    """
    if figs is None:
        figs = pylabtools.getfigs()

    if dir:
        mkdir_p(dir)

    for i, fig in enumerate(figs, 1):
        label = _get_title(fig)
        if label == '':
            label = "Figure_%d" % i
        if prefix:
            label = prefix + '_' + label
        filepath = os.path.join(dir, label+'.png')
        fig.savefig(filepath)

    close_figures()
コード例 #2
0
ファイル: imagefile.py プロジェクト: dmitryhits/charting
def save_images(dir='', figs=None, prefix=None):
    """
    Save all open figures to image files. 

    Parameters:
    ----------
    dir : string
        Directory to place image files into
    figs : list of Figures
        will default to open figures
    prefix : string
        prefix all image file names
    """
    if figs is None:
        figs = pylabtools.getfigs()

    if dir:
        mkdir_p(dir)

    for i, fig in enumerate(figs, 1):
        label = _get_title(fig)
        if label == '':
            label = "Figure_%d" % i
        if prefix:
            label = prefix + '_' + label
        filepath = os.path.join(dir, label+'.png')
        fig.savefig(filepath)

    close_figures()
コード例 #3
0
ファイル: imageIORoutines.py プロジェクト: peltonen/dattacode
def embed():
    """Simple method for embedding all current figures in the current ipython notebook cell.
    Use at the end of a cell.  Only works when the ipython notebook has been started with '--pylab'
    (note: NOT '--pylab=inline')"""

    # getfigs = pylabtools.getfigs

    display.display(*pylabtools.getfigs())
    plt.close('all')
コード例 #4
0
ファイル: imagefile.py プロジェクト: dmitryhits/charting
def save_to_pdf(file, figs=None):
    with PdfPages(file) as pdf:

        if figs is None:
            figs = pylabtools.getfigs()

        for fig in figs:
            fig.savefig(pdf, format='pdf')

    close_figures()
コード例 #5
0
ファイル: imagefile.py プロジェクト: andrewmhammond/trtools
def save_to_pdf(file, figs=None):
    pp = PdfPages(file)

    if figs is None:
        figs = pylabtools.getfigs()

    for fig in figs:
        fig.savefig(pp, format='pdf')

    pp.close()
    close_figures()
コード例 #6
0
def embed():
    """Simple method for embedding all current figures in the current ipython notebook cell.
    Use at the end of a cell.  Only works when the ipython notebook has been started with '--pylab'
    (note: NOT '--pylab=inline')

    NOTE:  DEPRECATED!!  Start ipython notebook with `ipython notebook` and include `%matplotlib inline`
    in the top cell instead!
    """

    display.display(*pylabtools.getfigs())
    plt.close('all')
コード例 #7
0
def save_to_pdf(file, figs=None):
    pp = PdfPages(file)

    if figs is None:
        figs = pylabtools.getfigs()

    for fig in figs:
        fig.savefig(pp, format='pdf')

    pp.close()
    close_figures()