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


Python cbook.is_numlike方法代码示例

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


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

示例1: from_any

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import is_numlike [as 别名]
def from_any(size, fraction_ref=None):
    """
    Creates Fixed unit when the first argument is a float, or a
    Fraction unit if that is a string that ends with %. The second
    argument is only meaningful when Fraction unit is created.::

      >>> a = Size.from_any(1.2) # => Size.Fixed(1.2)
      >>> Size.from_any("50%", a) # => Size.Fraction(0.5, a)

    """
    if cbook.is_numlike(size):
        return Fixed(size)
    elif cbook.is_string_like(size):
        if size[-1] == "%":
            return Fraction(float(size[:-1])/100., fraction_ref)

    raise ValueError("Unknown format") 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:axes_size.py

示例2: is_numlike

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import is_numlike [as 别名]
def is_numlike(x):
        """
        The matplotlib datalim, autoscaling, locators etc work with
        scalars which are the units converted to floats given the
        current unit.  The converter may be passed these floats, or
        arrays of them, even when units are set.  Derived conversion
        interfaces may opt to pass plain-ol unitless numbers through
        the conversion interface and this is a helper function for
        them.
        """
        if iterable(x):
            for thisx in x:
                return is_numlike(thisx)
        else:
            return is_numlike(x) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:units.py

示例3: offset_line

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import is_numlike [as 别名]
def offset_line(y, yerr):
    """
    Offsets an array *y* by +/- an error and returns a tuple (y - err, y + err).

    The error term can be:

    * A scalar. In this case, the returned tuple is obvious.
    * A vector of the same length as *y*. The quantities y +/- err are computed
      component-wise.
    * A tuple of length 2. In this case, yerr[0] is the error below *y* and
      yerr[1] is error above *y*. For example::

        from pylab import *
        x = linspace(0, 2*pi, num=100, endpoint=True)
        y = sin(x)
        y_minus, y_plus = mlab.offset_line(y, 0.1)
        plot(x, y)
        fill_between(x, ym, y2=yp)
        show()

    """
    if cbook.is_numlike(yerr) or (cbook.iterable(yerr) and len(yerr) == len(y)):
        ymin = y - yerr
        ymax = y + yerr
    elif len(yerr) == 2:
        ymin, ymax = y - yerr[0], y + yerr[1]
    else:
        raise ValueError("yerr must be scalar, 1xN or 2xN")
    return ymin, ymax 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:31,代码来源:mlab.py

示例4: offset_line

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import is_numlike [as 别名]
def offset_line(y, yerr):
    """
    Offsets an array *y* by +/- an error and returns a tuple
    (y - err, y + err).

    The error term can be:

    * A scalar. In this case, the returned tuple is obvious.
    * A vector of the same length as *y*. The quantities y +/- err are computed
      component-wise.
    * A tuple of length 2. In this case, yerr[0] is the error below *y* and
      yerr[1] is error above *y*. For example::

        import numpy as np
        import matplotlib.pyplot as plt

        x = np.linspace(0, 2*np.pi, num=100, endpoint=True)
        y = np.sin(x)
        y_minus, y_plus = mlab.offset_line(y, 0.1)
        plt.plot(x, y)
        plt.fill_between(x, y_minus, y2=y_plus)
        plt.show()

    """
    if cbook.is_numlike(yerr) or (cbook.iterable(yerr) and
                                  len(yerr) == len(y)):
        ymin = y - yerr
        ymax = y + yerr
    elif len(yerr) == 2:
        ymin, ymax = y - yerr[0], y + yerr[1]
    else:
        raise ValueError("yerr must be scalar, 1xN or 2xN")
    return ymin, ymax 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:35,代码来源:mlab.py

示例5: is_numlike

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import is_numlike [as 别名]
def is_numlike(x):
        """
        The Matplotlib datalim, autoscaling, locators etc work with
        scalars which are the units converted to floats given the
        current unit.  The converter may be passed these floats, or
        arrays of them, even when units are set.
        """
        if iterable(x):
            for thisx in x:
                return is_numlike(thisx)
        else:
            return is_numlike(x) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:14,代码来源:units.py

示例6: offset_line

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import is_numlike [as 别名]
def offset_line(y, yerr):
    """
    Offsets an array *y* by +/- an error and returns a tuple
    (y - err, y + err).

    The error term can be:

    * A scalar. In this case, the returned tuple is obvious.
    * A vector of the same length as *y*. The quantities y +/- err are computed
      component-wise.
    * A tuple of length 2. In this case, yerr[0] is the error below *y* and
      yerr[1] is error above *y*. For example::

        from pylab import *
        x = linspace(0, 2*pi, num=100, endpoint=True)
        y = sin(x)
        y_minus, y_plus = mlab.offset_line(y, 0.1)
        plot(x, y)
        fill_between(x, ym, y2=yp)
        show()

    """
    if cbook.is_numlike(yerr) or (cbook.iterable(yerr) and
                                  len(yerr) == len(y)):
        ymin = y - yerr
        ymax = y + yerr
    elif len(yerr) == 2:
        ymin, ymax = y - yerr[0], y + yerr[1]
    else:
        raise ValueError("yerr must be scalar, 1xN or 2xN")
    return ymin, ymax 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:33,代码来源:mlab.py


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