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


Python cbook.warn_deprecated函数代码示例

本文整理汇总了Python中matplotlib.cbook.warn_deprecated函数的典型用法代码示例。如果您正苦于以下问题:Python warn_deprecated函数的具体用法?Python warn_deprecated怎么用?Python warn_deprecated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: draggable

    def draggable(self, state=None, use_blit=False, update="loc"):
        """
        Set the draggable state -- if state is

          * None : toggle the current state

          * True : turn draggable on

          * False : turn draggable off

        If draggable is on, you can drag the legend on the canvas with
        the mouse. The `.DraggableLegend` helper instance is returned if
        draggable is on.

        The update parameter control which parameter of the legend changes
        when dragged. If update is "loc", the *loc* parameter of the legend
        is changed. If "bbox", the *bbox_to_anchor* parameter is changed.
        """
        warn_deprecated("2.2",
                        message="Legend.draggable() is drepecated in "
                                "favor of Legend.set_draggable(). "
                                "Legend.draggable may be reintroduced as a "
                                "property in future releases.")

        if state is None:
            state = not self.get_draggable()  # toggle state

        self.set_draggable(state, use_blit, update)

        return self._draggable
开发者ID:scott-vsi,项目名称:matplotlib,代码行数:30,代码来源:legend.py

示例2: show

    def show(*args, block=None, **kwargs):
        if args or kwargs:
            cbook.warn_deprecated(
                "3.1", message="Passing arguments to show(), other than "
                "passing 'block' by keyword, is deprecated %(since)s, and "
                "support for it will be removed %(removal)s.")

        ## TODO: something to do when keyword block==False ?
        from matplotlib._pylab_helpers import Gcf

        managers = Gcf.get_all_fig_managers()
        if not managers:
            return

        interactive = is_interactive()

        for manager in managers:
            manager.show()

            # plt.figure adds an event which puts the figure in focus
            # in the activeQue. Disable this behaviour, as it results in
            # figures being put as the active figure after they have been
            # shown, even in non-interactive mode.
            if hasattr(manager, '_cidgcf'):
                manager.canvas.mpl_disconnect(manager._cidgcf)

            if not interactive and manager in Gcf._activeQue:
                Gcf._activeQue.remove(manager)
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:28,代码来源:backend_nbagg.py

示例3: remove_coding

def remove_coding(text):
    r"""
    Remove the coding comment, which six.exec\_ doesn't like.
    """
    cbook.warn_deprecated('3.0', name='remove_coding', removal='3.1')
    sub_re = re.compile("^#\s*-\*-\s*coding:\s*.*-\*-$", flags=re.MULTILINE)
    return sub_re.sub("", text)
开发者ID:vapier,项目名称:matplotlib,代码行数:7,代码来源:plot_directive.py

示例4: _deprecate_factor_none

def _deprecate_factor_none(factor):
    # After the deprecation period, calls to _deprecate_factor_none can just be
    # removed.
    if factor is None:
        cbook.warn_deprecated(
            "3.2", "factor=None is deprecated; use/return factor=1 instead")
        factor = 1
    return factor
开发者ID:QuLogic,项目名称:matplotlib,代码行数:8,代码来源:grid_finder.py

示例5: __init__

 def __init__(self, figure):
     FigureCanvasBase.__init__(self, figure)
     if self.__class__ == matplotlib.backends.backend_gdk.FigureCanvasGDK:
         warn_deprecated('2.0', message="The GDK backend is "
                         "deprecated. It is untested, known to be "
                         "broken and will be removed in Matplotlib 2.2. "
                         "Use the Agg backend instead. "
                         "See Matplotlib usage FAQ for"
                         " more info on backends.",
                         alternative="Agg")
     self._renderer_init()
开发者ID:4over7,项目名称:matplotlib,代码行数:11,代码来源:backend_gdk.py

示例6: new_horizontal

    def new_horizontal(self, size, pad=None, pack_start=False, **kwargs):
        """
        Add a new axes on the right (or left) side of the main axes.

        Parameters
        ----------
        size : :mod:`~mpl_toolkits.axes_grid.axes_size` or float or string
            A width of the axes. If float or string is given, *from_any*
            function is used to create the size, with *ref_size* set to AxesX
            instance of the current axes.
        pad : :mod:`~mpl_toolkits.axes_grid.axes_size` or float or string
            Pad between the axes. It takes same argument as *size*.
        pack_start : bool
            If False, the new axes is appended at the end
            of the list, i.e., it became the right-most axes. If True, it is
            inserted at the start of the list, and becomes the left-most axes.
        **kwargs
            All extra keywords arguments are passed to the created axes.
            If *axes_class* is given, the new axes will be created as an
            instance of the given class. Otherwise, the same class of the
            main axes will be used.
        """
        if pad is None:
            cbook.warn_deprecated(
                "3.2", message="In a future version, 'pad' will default to "
                "rcParams['figure.subplot.wspace'].  Set pad=0 to keep the "
                "old behavior.")
        if pad:
            if not isinstance(pad, Size._Base):
                pad = Size.from_any(pad, fraction_ref=self._xref)
            if pack_start:
                self._horizontal.insert(0, pad)
                self._xrefindex += 1
            else:
                self._horizontal.append(pad)
        if not isinstance(size, Size._Base):
            size = Size.from_any(size, fraction_ref=self._xref)
        if pack_start:
            self._horizontal.insert(0, size)
            self._xrefindex += 1
            locator = self.new_locator(nx=0, ny=self._yrefindex)
        else:
            self._horizontal.append(size)
            locator = self.new_locator(
                nx=len(self._horizontal) - 1, ny=self._yrefindex)
        ax = self._get_new_axes(**kwargs)
        ax.set_axes_locator(locator)
        return ax
开发者ID:anntzer,项目名称:matplotlib,代码行数:48,代码来源:axes_divider.py

示例7: resize

    def resize(self, width, height=None):
        # before 09-12-22, the resize method takes a single *event*
        # parameter. On the other hand, the resize method of other
        # FigureManager class takes *width* and *height* parameter,
        # which is used to change the size of the window. For the
        # Figure.set_size_inches with forward=True work with Tk
        # backend, I changed the function signature but tried to keep
        # it backward compatible. -JJL

        # when a single parameter is given, consider it as a event
        if height is None:
            cbook.warn_deprecated("2.2", "FigureManagerTkAgg.resize now takes "
                                  "width and height as separate arguments")
            width = width.width
        else:
            self.canvas._tkcanvas.master.geometry("%dx%d" % (width, height))

        if self.toolbar is not None:
            self.toolbar.configure(width=width)
开发者ID:adnanb59,项目名称:matplotlib,代码行数:19,代码来源:backend_tkagg.py

示例8: set_zsort

    def set_zsort(self, zsort):
        """
        Sets the calculation method for the z-order.

        Parameters
        ----------
        zsort : {'average', 'min', 'max'}
            The function applied on the z-coordinates of the vertices in the
            viewer's coordinate system, to determine the z-order.  *True* is
            deprecated and equivalent to 'average'.
        """
        if zsort is True:
            cbook.warn_deprecated(
                "3.1", "Passing True to mean 'average' for set_zsort is "
                "deprecated and support will be removed in Matplotlib 3.3; "
                "pass 'average' instead.")
            zsort = 'average'
        self._zsortfunc = self._zsort_functions[zsort]
        self._sort_zpos = None
        self.stale = True
开发者ID:dopplershift,项目名称:matplotlib,代码行数:20,代码来源:art3d.py

示例9: get_subplot_params

    def get_subplot_params(self, figure=None, fig=None):
        """
        Return a dictionary of subplot layout parameters. The default
        parameters are from rcParams unless a figure attribute is set.
        """
        if fig is not None:
            cbook.warn_deprecated("2.2", "fig", obj_type="keyword argument",
                                  alternative="figure")
        if figure is None:
            figure = fig

        if figure is None:
            kw = {k: rcParams["figure.subplot."+k] for k in self._AllowedKeys}
            subplotpars = mpl.figure.SubplotParams(**kw)
        else:
            subplotpars = copy.copy(figure.subplotpars)

        subplotpars.update(**{k: getattr(self, k) for k in self._AllowedKeys})

        return subplotpars
开发者ID:dopplershift,项目名称:matplotlib,代码行数:20,代码来源:gridspec.py

示例10: __init__

    def __init__(self, figure):
        if self.__class__ == matplotlib.backends.backend_gtk.FigureCanvasGTK:
            warn_deprecated(
                "2.0",
                message="The GTK backend is "
                "deprecated. It is untested, known to be "
                "broken and will be removed in Matplotlib 2.2. "
                "Use the GTKAgg backend instead. "
                "See Matplotlib usage FAQ for"
                " more info on backends.",
                alternative="GTKAgg",
            )
        if _debug:
            print("FigureCanvasGTK.%s" % fn_name())
        FigureCanvasBase.__init__(self, figure)
        gtk.DrawingArea.__init__(self)

        self._idle_draw_id = 0
        self._need_redraw = True
        self._pixmap_width = -1
        self._pixmap_height = -1
        self._lastCursor = None

        self.connect("scroll_event", self.scroll_event)
        self.connect("button_press_event", self.button_press_event)
        self.connect("button_release_event", self.button_release_event)
        self.connect("configure_event", self.configure_event)
        self.connect("expose_event", self.expose_event)
        self.connect("key_press_event", self.key_press_event)
        self.connect("key_release_event", self.key_release_event)
        self.connect("motion_notify_event", self.motion_notify_event)
        self.connect("leave_notify_event", self.leave_notify_event)
        self.connect("enter_notify_event", self.enter_notify_event)

        self.set_events(self.__class__.event_mask)

        self.set_double_buffered(False)
        self.set_flags(gtk.CAN_FOCUS)
        self._renderer_init()

        self.last_downclick = {}
开发者ID:QuLogic,项目名称:matplotlib,代码行数:41,代码来源:backend_gtk.py

示例11: warn_deprecated

from . import axes_size as Size
from .axes_divider import Divider, SubplotDivider, LocatableAxes, \
     make_axes_locatable
from .axes_grid import Grid, ImageGrid, AxesGrid
#from axes_divider import make_axes_locatable
from matplotlib.cbook import warn_deprecated
warn_deprecated(since='2.1',
                name='mpl_toolkits.axes_grid',
                alternative='mpl_toolkits.axes_grid1 and'
                            ' mpl_toolkits.axisartist provies the same'
                            ' functionality',
                obj_type='module')
开发者ID:endolith,项目名称:matplotlib,代码行数:12,代码来源:__init__.py

示例12: __init__


#.........这里部分代码省略.........
        # introduce y-offset for handles of the scatter plot
        if scatteryoffsets is None:
            self._scatteryoffsets = np.array([3. / 8., 4. / 8., 2.5 / 8.])
        else:
            self._scatteryoffsets = np.asarray(scatteryoffsets)
        reps = self.scatterpoints // len(self._scatteryoffsets) + 1
        self._scatteryoffsets = np.tile(self._scatteryoffsets,
                                        reps)[:self.scatterpoints]

        # _legend_box is an OffsetBox instance that contains all
        # legend items and will be initialized from _init_legend_box()
        # method.
        self._legend_box = None

        if isinstance(parent, Axes):
            self.isaxes = True
            self.axes = parent
            self.set_figure(parent.figure)
        elif isinstance(parent, Figure):
            self.isaxes = False
            self.set_figure(parent)
        else:
            raise TypeError("Legend needs either Axes or Figure as parent")
        self.parent = parent

        self._loc_used_default = loc is None
        if loc is None:
            loc = rcParams["legend.loc"]
            if not self.isaxes and loc in [0, 'best']:
                loc = 'upper right'
        if isinstance(loc, str):
            if loc not in self.codes:
                if self.isaxes:
                    cbook.warn_deprecated(
                        "3.1", message="Unrecognized location {!r}. Falling "
                        "back on 'best'; valid locations are\n\t{}\n"
                        "This will raise an exception %(removal)s."
                        .format(loc, '\n\t'.join(self.codes)))
                    loc = 0
                else:
                    cbook.warn_deprecated(
                        "3.1", message="Unrecognized location {!r}. Falling "
                        "back on 'upper right'; valid locations are\n\t{}\n'"
                        "This will raise an exception %(removal)s."
                        .format(loc, '\n\t'.join(self.codes)))
                    loc = 1
            else:
                loc = self.codes[loc]
        if not self.isaxes and loc == 0:
            cbook.warn_deprecated(
                "3.1", message="Automatic legend placement (loc='best') not "
                "implemented for figure legend. Falling back on 'upper "
                "right'. This will raise an exception %(removal)s.")
            loc = 1

        self._mode = mode
        self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform)

        # We use FancyBboxPatch to draw a legend frame. The location
        # and size of the box will be updated during the drawing time.

        if facecolor is None:
            facecolor = rcParams["legend.facecolor"]
        if facecolor == 'inherit':
            facecolor = rcParams["axes.facecolor"]
开发者ID:jklymak,项目名称:matplotlib,代码行数:66,代码来源:legend.py

示例13: GetForegroundWindow

"""
MS Windows-specific helper for the TkAgg backend.

With rcParams['tk.window_focus'] default of False, it is
effectively disabled.

It uses a tiny C++ extension module to access MS Win functions.

This module is deprecated and will be removed in version 3.2
"""

from matplotlib import rcParams, cbook

cbook.warn_deprecated('3.0', obj_type='module', name='backends.windowing')

try:
    if not rcParams['tk.window_focus']:
        raise ImportError
    from matplotlib._windowing import GetForegroundWindow, SetForegroundWindow

except ImportError:

    def GetForegroundWindow():
        return 0

    def SetForegroundWindow(hwnd):
        pass


class FocusManager(object):
    def __init__(self):
开发者ID:dopplershift,项目名称:matplotlib,代码行数:31,代码来源:windowing.py

示例14: import

"""
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

import six

import copy
import numpy as np

import xlwt as excel

import matplotlib.cbook as cbook
import matplotlib.mlab as mlab


cbook.warn_deprecated("2.0", name="mpl_toolkits.exceltools",
                      alternative="openpyxl", obj_type="module")


def xlformat_factory(format):
    """
    copy the format, perform any overrides, and attach an xlstyle instance
    copied format is returned
    """

    #if we have created an excel format already using this format,
    #don't recreate it; mlab.FormatObj override has to make objs with
    #the same props hash to the same value
    key = hash(format)
    fmt_ = xlformat_factory.created_formats.get(key)
    if fmt_ is not None:
        return fmt_
开发者ID:4over7,项目名称:matplotlib,代码行数:32,代码来源:exceltools.py

示例15: _init_legend_box

    def _init_legend_box(self, handles, labels, markerfirst=True):
        """
        Initialize the legend_box. The legend_box is an instance of
        the OffsetBox, which is packed with legend handles and
        texts. Once packed, their location is calculated during the
        drawing time.
        """

        fontsize = self._fontsize

        # legend_box is a HPacker, horizontally packed with
        # columns. Each column is a VPacker, vertically packed with
        # legend items. Each legend item is HPacker packed with
        # legend handleBox and labelBox. handleBox is an instance of
        # offsetbox.DrawingArea which contains legend handle. labelBox
        # is an instance of offsetbox.TextArea which contains legend
        # text.

        text_list = []  # the list of text instances
        handle_list = []  # the list of text instances

        label_prop = dict(verticalalignment='baseline',
                          horizontalalignment='left',
                          fontproperties=self.prop,
                          )

        labelboxes = []
        handleboxes = []

        # The approximate height and descent of text. These values are
        # only used for plotting the legend handle.
        descent = 0.35 * self._approx_text_height() * (self.handleheight - 0.7)
        # 0.35 and 0.7 are just heuristic numbers and may need to be improved.
        height = self._approx_text_height() * self.handleheight - descent
        # each handle needs to be drawn inside a box of (x, y, w, h) =
        # (0, -descent, width, height).  And their coordinates should
        # be given in the display coordinates.

        # The transformation of each handle will be automatically set
        # to self.get_trasnform(). If the artist does not use its
        # default transform (e.g., Collections), you need to
        # manually set their transform to the self.get_transform().
        legend_handler_map = self.get_legend_handler_map()

        for orig_handle, lab in zip(handles, labels):
            handler = self.get_legend_handler(legend_handler_map, orig_handle)
            if handler is None:
                warnings.warn(
                    "Legend does not support {!r} instances.\nA proxy artist "
                    "may be used instead.\nSee: "
                    "http://matplotlib.org/users/legend_guide.html"
                    "#using-proxy-artist".format(orig_handle)
                )
                # We don't have a handle for this artist, so we just defer
                # to None.
                handle_list.append(None)
            else:
                textbox = TextArea(lab, textprops=label_prop,
                                   multilinebaseline=True,
                                   minimumdescent=True)
                text_list.append(textbox._text)

                labelboxes.append(textbox)

                handlebox = DrawingArea(width=self.handlelength * fontsize,
                                        height=height,
                                        xdescent=0., ydescent=descent)
                handleboxes.append(handlebox)

                # Deprecate the old behaviour of accepting callable
                # legend handlers in favour of the "legend_artist"
                # interface.
                if (not hasattr(handler, 'legend_artist') and
                        callable(handler)):
                    handler.legend_artist = handler.__call__
                    warn_deprecated('1.4',
                                    ('Legend handers must now implement a '
                                     '"legend_artist" method rather than '
                                     'being a callable.'))

                # Create the artist for the legend which represents the
                # original artist/handle.
                handle_list.append(handler.legend_artist(self, orig_handle,
                                                         fontsize, handlebox))

        if len(handleboxes) > 0:

            # We calculate number of rows in each column. The first
            # (num_largecol) columns will have (nrows+1) rows, and remaining
            # (num_smallcol) columns will have (nrows) rows.
            ncol = min(self._ncol, len(handleboxes))
            nrows, num_largecol = divmod(len(handleboxes), ncol)
            num_smallcol = ncol - num_largecol

            # starting index of each column and number of rows in it.
            largecol = safezip(list(xrange(0,
                                           num_largecol * (nrows + 1),
                                           (nrows + 1))),
                               [nrows + 1] * num_largecol)
            smallcol = safezip(list(xrange(num_largecol * (nrows + 1),
#.........这里部分代码省略.........
开发者ID:BigheadLiu,项目名称:matplotlib,代码行数:101,代码来源:legend.py


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