当前位置: 首页>>代码示例>>Python>>正文


Python matplotlib.pylab方法代码示例

本文整理汇总了Python中matplotlib.pylab方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib.pylab方法的具体用法?Python matplotlib.pylab怎么用?Python matplotlib.pylab使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib的用法示例。


在下文中一共展示了matplotlib.pylab方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: vPlotEquityCurves

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def vPlotEquityCurves(oBt, mOhlc, oChefModule,
                      sPeriod='W',
                      close_label='C',):
    import matplotlib
    import matplotlib.pylab as pylab
    # FixMe:
    matplotlib.rcParams['figure.figsize'] = (10, 5)

    # FixMe: derive the period from the sTimeFrame
    oChefModule.vPlotEquity(oBt.equity, mOhlc, sTitle="%s\nEquity" % repr(oBt),
                            sPeriod=sPeriod,
                            close_label=close_label,
                            )
    pylab.show()

    oBt.vPlotTrades()
    pylab.legend(loc='lower left')
    pylab.show()

    ## oBt.vPlotTrades(subset=slice(sYear+'-05-01', sYear+'-09-01'))
    ## pylab.legend(loc='lower left')
    ## pylab.show() 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:24,代码来源:OTBackTest.py

示例2: show

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def show(*args, **kw):
    """
    Display a figure.

    When running in ipython with its pylab mode, display all
    figures and return to the ipython prompt.

    In non-interactive mode, display all figures and block until
    the figures have been closed; in interactive mode it has no
    effect unless figures were created prior to a change from
    non-interactive to interactive mode (not recommended).  In
    that case it displays the figures but does not block.

    A single experimental keyword argument, *block*, may be
    set to True or False to override the blocking behavior
    described above.
    """
    global _show
    _show(*args, **kw) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:pyplot.py

示例3: activate_matplotlib

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def activate_matplotlib(backend):
    """Activate the given backend and set interactive to True."""

    import matplotlib
    matplotlib.interactive(True)
    
    # Matplotlib had a bug where even switch_backend could not force
    # the rcParam to update. This needs to be set *before* the module
    # magic of switch_backend().
    matplotlib.rcParams['backend'] = backend

    import matplotlib.pyplot
    matplotlib.pyplot.switch_backend(backend)

    # This must be imported last in the matplotlib series, after
    # backend/interactivity choices have been made
    import matplotlib.pylab as pylab

    pylab.show._needmain = False
    # We need to detect at runtime whether show() is called by the user.
    # For this, we wrap it into a decorator which adds a 'called' flag.
    pylab.draw_if_interactive = flag_calls(pylab.draw_if_interactive) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,代码来源:pylabtools.py

示例4: show

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def show(*args, **kw):
    """
    Display a figure.
    When running in ipython with its pylab mode, display all
    figures and return to the ipython prompt.

    In non-interactive mode, display all figures and block until
    the figures have been closed; in interactive mode it has no
    effect unless figures were created prior to a change from
    non-interactive to interactive mode (not recommended).  In
    that case it displays the figures but does not block.

    A single experimental keyword argument, *block*, may be
    set to True or False to override the blocking behavior
    described above.
    """
    global _show
    return _show(*args, **kw) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:20,代码来源:pyplot.py

示例5: _show_video

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def _show_video(video, fps=10):
    # Import matplotlib/pylab only if needed
    import matplotlib
    matplotlib.use('TkAgg')
    import matplotlib.pylab as pl
    pl.style.use('ggplot')
    pl.axis('off')

    if fps < 0:
        fps = 25
    video /= 255.  # Pylab works in [0, 1] range
    img = None
    pause_length = 1. / fps
    try:
        for f in range(video.shape[0]):
            im = video[f, :, :, :]
            if img is None:
                img = pl.imshow(im)
            else:
                img.set_data(im)
            pl.pause(pause_length)
            pl.draw()
    except:
        pass 
开发者ID:victorcampos7,项目名称:tensorflow-ffmpeg,代码行数:26,代码来源:usage_example.py

示例6: drawMapqHistogram

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def drawMapqHistogram(self):
        """ From matplot lib plots a Mappping qualty histogram
        """
        #1. PLOT BUILDING
        readsMapq = self.mapping_stats.mapping_quality_reads
       
        mapqList = list(range(len(readsMapq)))
     
        matplotlib.pyplot.ioff()
        figure = plt.figure()
        plt.bar(mapqList,readsMapq,width=1,align='center',facecolor='blue', alpha=0.75)
        plt.xlabel('MapQ')
        plt.ylabel('Fragments')
        plt.title('MapQ Histogram')
        plt.axis([0, 60,min(readsMapq), max(readsMapq)])
        plt.grid(True)
        
        pylab.savefig(self.png_mapq_histogram)
        
        plt.close(figure) 
开发者ID:heathsc,项目名称:gemBS,代码行数:22,代码来源:reportStats.py

示例7: update_current_task

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def update_current_task(task):
        # make sure we have a default vale
        if PatchedMatplotlib._global_image_counter_limit is None:
            from ..config import config
            PatchedMatplotlib._global_image_counter_limit = config.get('metric.matplotlib_untitled_history_size', 100)

        # if we already patched it, just update the current task
        if PatchedMatplotlib._patched_original_plot is not None:
            PatchedMatplotlib._current_task = task
        # if matplotlib is not loaded yet, get a callback hook
        elif not running_remotely() and \
                ('matplotlib.pyplot' not in sys.modules and 'matplotlib.pylab' not in sys.modules):
            PatchedMatplotlib._current_task = task
            PostImportHookPatching.add_on_import('matplotlib.pyplot', PatchedMatplotlib.patch_matplotlib)
            PostImportHookPatching.add_on_import('matplotlib.pylab', PatchedMatplotlib.patch_matplotlib)
        elif PatchedMatplotlib.patch_matplotlib():
            PatchedMatplotlib._current_task = task 
开发者ID:allegroai,项目名称:trains,代码行数:19,代码来源:matplotlib_bind.py

示例8: _plot_to_string

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def _plot_to_string():
    try:
        from StringIO import StringIO
        make_bytes = lambda x: x.buf
    except ImportError:
        from io import BytesIO as StringIO
        make_bytes = lambda x: x.getbuffer()
    try:
        from urllib import quote
    except:
        from urllib.parse import quote
    import base64
    import matplotlib.pylab as plt
    imgdata = StringIO()
    plt.savefig(imgdata)
    plt.close()
    imgdata.seek(0) 
    image = base64.encodestring(make_bytes(imgdata))
    return str(quote(image)) 
开发者ID:jahuth,项目名称:convis,代码行数:21,代码来源:variable_describe.py

示例9: _onEnter

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def _onEnter(self, evt):
        """Mouse has entered the window."""
        FigureCanvasBase.enter_notify_event(self, guiEvent = evt)


########################################################################
#
# The following functions and classes are for pylab compatibility
# mode (matplotlib.pylab) and implement figure managers, etc...
#
######################################################################## 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:13,代码来源:backend_wx.py

示例10: new_figure_manager

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def new_figure_manager(num, *args, **kwargs):
    """
    Create a new figure manager instance
    """
    # in order to expose the Figure constructor to the pylab
    # interface we need to create the figure here
    DEBUG_MSG("new_figure_manager()", 3, None)
    _create_wx_app()

    FigureClass = kwargs.pop('FigureClass', Figure)
    fig = FigureClass(*args, **kwargs)
    return new_figure_manager_given_figure(num, fig) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:14,代码来源:backend_wx.py

示例11: mpl_runner

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def mpl_runner(safe_execfile):
    """Factory to return a matplotlib-enabled runner for %run.

    Parameters
    ----------
    safe_execfile : function
      This must be a function with the same interface as the
      :meth:`safe_execfile` method of IPython.

    Returns
    -------
    A function suitable for use as the ``runner`` argument of the %run magic
    function.
    """
    
    def mpl_execfile(fname,*where,**kw):
        """matplotlib-aware wrapper around safe_execfile.

        Its interface is identical to that of the :func:`execfile` builtin.

        This is ultimately a call to execfile(), but wrapped in safeties to
        properly handle interactive rendering."""

        import matplotlib
        import matplotlib.pylab as pylab

        #print '*** Matplotlib runner ***' # dbg
        # turn off rendering until end of script
        is_interactive = matplotlib.rcParams['interactive']
        matplotlib.interactive(False)
        safe_execfile(fname,*where,**kw)
        matplotlib.interactive(is_interactive)
        # make rendering call now, if the user tried to do it
        if pylab.draw_if_interactive.called:
            pylab.draw()
            pylab.draw_if_interactive.called = False

    return mpl_execfile 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:40,代码来源:pylabtools.py

示例12: select_figure_format

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def select_figure_format(shell, fmt):
    """Select figure format for inline backend, can be 'png', 'retina', or 'svg'.

    Using this method ensures only one figure format is active at a time.
    """
    from matplotlib.figure import Figure
    from IPython.kernel.zmq.pylab import backend_inline

    svg_formatter = shell.display_formatter.formatters['image/svg+xml']
    png_formatter = shell.display_formatter.formatters['image/png']

    if fmt == 'png':
        svg_formatter.type_printers.pop(Figure, None)
        png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png'))
    elif fmt in ('png2x', 'retina'):
        svg_formatter.type_printers.pop(Figure, None)
        png_formatter.for_type(Figure, retina_figure)
    elif fmt == 'svg':
        png_formatter.type_printers.pop(Figure, None)
        svg_formatter.for_type(Figure, lambda fig: print_figure(fig, 'svg'))
    else:
        raise ValueError("supported formats are: 'png', 'retina', 'svg', not %r" % fmt)

    # set the format to be used in the backend()
    backend_inline._figure_format = fmt

#-----------------------------------------------------------------------------
# Code for initializing matplotlib and importing pylab
#----------------------------------------------------------------------------- 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:31,代码来源:pylabtools.py

示例13: import_pylab

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def import_pylab(user_ns, import_all=True):
    """Populate the namespace with pylab-related values.
    
    Imports matplotlib, pylab, numpy, and everything from pylab and numpy.
    
    Also imports a few names from IPython (figsize, display, getfigs)
    
    """

    # Import numpy as np/pyplot as plt are conventions we're trying to
    # somewhat standardize on.  Making them available to users by default
    # will greatly help this.
    s = ("import numpy\n"
          "import matplotlib\n"
          "from matplotlib import pylab, mlab, pyplot\n"
          "np = numpy\n"
          "plt = pyplot\n"
          )
    exec s in user_ns
    
    if import_all:
        s = ("from matplotlib.pylab import *\n"
             "from numpy import *\n")
        exec s in user_ns
    
    # IPython symbols to add
    user_ns['figsize'] = figsize
    from IPython.core.display import display
    # Add display and getfigs to the user's namespace
    user_ns['display'] = display
    user_ns['getfigs'] = getfigs 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:33,代码来源:pylabtools.py

示例14: saveAndClose

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def saveAndClose(self):
        """Save the figure and close it"""
        pylab.savefig(self.pngFile)
        plt.close(self.figure) 
开发者ID:heathsc,项目名称:gemBS,代码行数:6,代码来源:bsCallStats.py

示例15: drawInsertSizePlot

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import pylab [as 别名]
def drawInsertSizePlot(self):
        """ From matplot lib plots a Insert Size Plot
        """
        iSizeList = []
        readsList = []
        
        #1. PLOT BUILDING
        histogram_template_len = self.mapping_stats.read_insert_size_histogram
        
        for insert_size_length,reads in histogram_template_len.items():
            iSizeList.append(int(insert_size_length))
            readsList.append(int(reads))
            
        matplotlib.pyplot.ioff()            
        figure = plt.figure()

        plt.plot(iSizeList, readsList, '.',color="r")
        plt.xlabel('Insert Size (bp)')
        plt.ylabel('Reads')
        plt.title('Insert Size Histogram')
        plt.axis([min(iSizeList), 800,min(readsList), max(readsList)])
        plt.grid(True)
        
        pylab.savefig(self.png_insert_size_histogram)
        
        plt.close(figure) 
开发者ID:heathsc,项目名称:gemBS,代码行数:28,代码来源:reportStats.py


注:本文中的matplotlib.pylab方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。