• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python cbook.warn_deprecated函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: _wants_nose

def _wants_nose():
    wants_nose = (not getattr(mpl, '_called_from_pytest', False)
                  and 'nose' in sys.modules)
    if wants_nose:
        cbook.warn_deprecated("3.2", name="support for nose-based tests")
    return wants_nose
开发者ID:anntzer,项目名称:matplotlib,代码行数:6,代码来源:__init__.py


示例17:

"""
.. note:: Deprecated in 1.3
"""
import warnings
from matplotlib import cbook
cbook.warn_deprecated(
    '1.3', name='matplotlib.mpl', alternative='`import matplotlib as mpl`',
    obj_type='module')
from matplotlib import artist
from matplotlib import axis
from matplotlib import axes
from matplotlib import collections
from matplotlib import colors
from matplotlib import colorbar
from matplotlib import contour
from matplotlib import dates
from matplotlib import figure
from matplotlib import finance
from matplotlib import font_manager
from matplotlib import image
from matplotlib import legend
from matplotlib import lines
from matplotlib import mlab
from matplotlib import cm
from matplotlib import patches
from matplotlib import quiver
from matplotlib import rcParams
from matplotlib import table
from matplotlib import text
from matplotlib import ticker
from matplotlib import transforms
开发者ID:J-Hou,项目名称:matplotlib-4-abaqus,代码行数:31,代码来源:mpl.py


示例18: import

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

import six
from six.moves import xrange, zip

import copy
import gtk, gobject
import numpy as np
import matplotlib.cbook as cbook
from matplotlib.cbook import warn_deprecated
import matplotlib.mlab as mlab


warn_deprecated("2.0", name="mpl_toolkits.gtktools", obj_type="module")


def error_message(msg, parent=None, title=None):
    """
    create an error message dialog with string msg.  Optionally set
    the parent widget and dialog title
    """

    dialog = gtk.MessageDialog(
        parent         = None,
        type           = gtk.MESSAGE_ERROR,
        buttons        = gtk.BUTTONS_OK,
        message_format = msg)
    if parent is not None:
        dialog.set_transient_for(parent)
开发者ID:RealGeeks,项目名称:matplotlib,代码行数:31,代码来源:gtktools.py


示例19: warn_deprecated

"""
A replacement wrapper around the subprocess module, which provides a stub
implementation of subprocess members on Google App Engine
(which are missing in subprocess).

Instead of importing subprocess, other modules should use this as follows:

from matplotlib.compat import subprocess

This module is safe to import from anywhere within matplotlib.
"""
import subprocess
from matplotlib.cbook import warn_deprecated
warn_deprecated(since='3.0',
                name='matplotlib.compat.subprocess',
                alternative='the python 3 standard library '
                            '"subprocess" module',
                obj_type='module')

__all__ = ['Popen', 'PIPE', 'STDOUT', 'check_output', 'CalledProcessError']


if hasattr(subprocess, 'Popen'):
    Popen = subprocess.Popen
    # Assume that it also has the other constants.
    PIPE = subprocess.PIPE
    STDOUT = subprocess.STDOUT
    CalledProcessError = subprocess.CalledProcessError
    check_output = subprocess.check_output
else:
    # In restricted environments (such as Google App Engine), these are
开发者ID:DanHickstein,项目名称:matplotlib,代码行数:31,代码来源:subprocess.py


示例20: warn_deprecated

import datetime

import numpy as np

from matplotlib import colors as mcolors, verbose, get_cachedir
from matplotlib.dates import date2num
from matplotlib.cbook import iterable, mkdirs, warn_deprecated
from matplotlib.collections import LineCollection, PolyCollection
from matplotlib.lines import Line2D, TICKLEFT, TICKRIGHT
from matplotlib.patches import Rectangle
from matplotlib.transforms import Affine2D

warn_deprecated(
    since=2.0,
    message=("The finance module has been deprecated in mpl 2.0 and will "
             "be removed in mpl 2.2. Please use the module mpl_finance "
             "instead."))


if six.PY3:
    import hashlib

    def md5(x):
        return hashlib.md5(x.encode())
else:
    from hashlib import md5

cachedir = get_cachedir()
# cachedir will be None if there is no writable directory.
if cachedir is not None:
开发者ID:Eric89GXL,项目名称:matplotlib,代码行数:30,代码来源:finance.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cm.get_cmap函数代码示例发布时间:2022-05-27
下一篇:
Python cbook.unicode_safe函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap