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


Python polar.PolarAxes方法代码示例

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


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

示例1: axisinfo

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def axisinfo( unit, axis ):
      """: Returns information on how to handle an axis that has Epoch data.

      = INPUT VARIABLES
      - unit    The units to use for a axis with Epoch data.

      = RETURN VALUE
      - Returns a matplotlib AxisInfo data structure that contains
        minor/major formatters, major/minor locators, and default
        label information.
      """
      # Delay-load due to circular dependencies.
      import matplotlib.testing.jpl_units as U

      # Check to see if the value used for units is a string unit value
      # or an actual instance of a UnitDbl so that we can use the unit
      # value for the default axis label value.
      if ( unit ):
         if ( isinstance( unit, str ) ):
            label = unit
         else:
            label = unit.label()
      else:
         label = None

      if ( label == "deg" ) and isinstance( axis.axes, polar.PolarAxes ):
         # If we want degrees for a polar plot, use the PolarPlotFormatter
         majfmt = polar.PolarAxes.ThetaFormatter()
      else:
         majfmt = U.UnitDblFormatter( useOffset = False )

      return units.AxisInfo( majfmt = majfmt, label = label )

   #------------------------------------------------------------------------ 
开发者ID:Solid-Mechanics,项目名称:matplotlib-4-abaqus,代码行数:36,代码来源:UnitDblConverter.py

示例2: axisinfo

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def axisinfo( unit, axis ):
      """: Returns information on how to handle an axis that has Epoch data.

      = INPUT VARIABLES
      - unit    The units to use for a axis with Epoch data.

      = RETURN VALUE
      - Returns a matplotlib AxisInfo data structure that contains
        minor/major formatters, major/minor locators, and default
        label information.
      """
      # Delay-load due to circular dependencies.
      import matplotlib.testing.jpl_units as U

      # Check to see if the value used for units is a string unit value
      # or an actual instance of a UnitDbl so that we can use the unit
      # value for the default axis label value.
      if ( unit ):
         if ( isinstance( unit, six.string_types ) ):
            label = unit
         else:
            label = unit.label()
      else:
         label = None

      if ( label == "deg" ) and isinstance( axis.axes, polar.PolarAxes ):
         # If we want degrees for a polar plot, use the PolarPlotFormatter
         majfmt = polar.PolarAxes.ThetaFormatter()
      else:
         majfmt = U.UnitDblFormatter( useOffset = False )

      return units.AxisInfo( majfmt = majfmt, label = label )

   #------------------------------------------------------------------------ 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:36,代码来源:UnitDblConverter.py

示例3: axisinfo

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def axisinfo(unit, axis):
        """: Returns information on how to handle an axis that has Epoch data.

        = INPUT VARIABLES
        - unit     The units to use for a axis with Epoch data.

        = RETURN VALUE
        - Returns a matplotlib AxisInfo data structure that contains
          minor/major formatters, major/minor locators, and default
          label information.
        """
        # Delay-load due to circular dependencies.
        import matplotlib.testing.jpl_units as U

        # Check to see if the value used for units is a string unit value
        # or an actual instance of a UnitDbl so that we can use the unit
        # value for the default axis label value.
        if unit:
            label = unit if isinstance(unit, str) else unit.label()
        else:
            label = None

        if (label == "deg") and isinstance(axis.axes, polar.PolarAxes):
            # If we want degrees for a polar plot, use the PolarPlotFormatter
            majfmt = polar.PolarAxes.ThetaFormatter()
        else:
            majfmt = U.UnitDblFormatter(useOffset=False)

        return units.AxisInfo(majfmt=majfmt, label=label)

    # ----------------------------------------------------------------------- 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:33,代码来源:UnitDblConverter.py

示例4: axisinfo

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def axisinfo(unit, axis):
        """: Returns information on how to handle an axis that has Epoch data.

        = INPUT VARIABLES
        - unit     The units to use for a axis with Epoch data.

        = RETURN VALUE
        - Returns a matplotlib AxisInfo data structure that contains
          minor/major formatters, major/minor locators, and default
          label information.
        """
        # Delay-load due to circular dependencies.
        import matplotlib.testing.jpl_units as U

        # Check to see if the value used for units is a string unit value
        # or an actual instance of a UnitDbl so that we can use the unit
        # value for the default axis label value.
        if unit:
            label = unit if isinstance(unit, str) else unit.label()
        else:
            label = None

        if label == "deg" and isinstance(axis.axes, polar.PolarAxes):
            # If we want degrees for a polar plot, use the PolarPlotFormatter
            majfmt = polar.PolarAxes.ThetaFormatter()
        else:
            majfmt = U.UnitDblFormatter(useOffset=False)

        return units.AxisInfo(majfmt=majfmt, label=label) 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:31,代码来源:UnitDblConverter.py

示例5: convert

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def convert( value, unit, axis ):
      """: Convert value using unit to a float.  If value is a sequence, return
      the converted sequence.

      = INPUT VARIABLES
      - value   The value or list of values that need to be converted.
      - unit    The units to use for a axis with Epoch data.

      = RETURN VALUE
      - Returns the value parameter converted to floats.
      """
      # Delay-load due to circular dependencies.
      import matplotlib.testing.jpl_units as U

      isNotUnitDbl = True

      if ( iterable(value) and not isinstance(value, str) ):
         if ( len(value) == 0 ):
            return []
         else:
            return [ UnitDblConverter.convert( x, unit, axis ) for x in value ]

      # We need to check to see if the incoming value is actually a UnitDbl and
      # set a flag.  If we get an empty list, then just return an empty list.
      if ( isinstance(value, U.UnitDbl) ):
         isNotUnitDbl = False

      # If the incoming value behaves like a number, but is not a UnitDbl,
      # then just return it because we don't know how to convert it
      # (or it is already converted)
      if ( isNotUnitDbl and units.ConversionInterface.is_numlike( value ) ):
         return value

      # If no units were specified, then get the default units to use.
      if ( unit == None ):
         unit = UnitDblConverter.default_units( value, axis )

      # Convert the incoming UnitDbl value/values to float/floats
      if isinstance( axis.axes, polar.PolarAxes ) and (value.type() == "angle"):
         # Guarantee that units are radians for polar plots.
         return value.convert( "rad" )

      return value.convert( unit )

   #------------------------------------------------------------------------ 
开发者ID:Solid-Mechanics,项目名称:matplotlib-4-abaqus,代码行数:47,代码来源:UnitDblConverter.py

示例6: test_as_mpl_axes_api

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def test_as_mpl_axes_api():
    # tests the _as_mpl_axes api
    from matplotlib.projections.polar import PolarAxes
    import matplotlib.axes as maxes

    class Polar(object):
        def __init__(self):
            self.theta_offset = 0

        def _as_mpl_axes(self):
            # implement the matplotlib axes interface
            return PolarAxes, {'theta_offset': self.theta_offset}
    prj = Polar()
    prj2 = Polar()
    prj2.theta_offset = np.pi
    prj3 = Polar()

    # testing axes creation with plt.axes
    ax = plt.axes([0, 0, 1, 1], projection=prj)
    assert type(ax) == PolarAxes, \
        'Expected a PolarAxes, got %s' % type(ax)
    ax_via_gca = plt.gca(projection=prj)
    assert ax_via_gca is ax
    plt.close()

    # testing axes creation with gca
    ax = plt.gca(projection=prj)
    assert type(ax) == maxes._subplots._subplot_classes[PolarAxes], \
        'Expected a PolarAxesSubplot, got %s' % type(ax)
    ax_via_gca = plt.gca(projection=prj)
    assert ax_via_gca is ax
    # try getting the axes given a different polar projection
    ax_via_gca = plt.gca(projection=prj2)
    assert ax_via_gca is not ax
    assert ax.get_theta_offset() == 0, ax.get_theta_offset()
    assert ax_via_gca.get_theta_offset() == np.pi, ax_via_gca.get_theta_offset()
    # try getting the axes given an == (not is) polar projection
    ax_via_gca = plt.gca(projection=prj3)
    assert ax_via_gca is ax
    plt.close()

    # testing axes creation with subplot
    ax = plt.subplot(121, projection=prj)
    assert type(ax) == maxes._subplots._subplot_classes[PolarAxes], \
        'Expected a PolarAxesSubplot, got %s' % type(ax)
    plt.close() 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:48,代码来源:test_axes.py

示例7: convert

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def convert( value, unit, axis ):
      """: Convert value using unit to a float.  If value is a sequence, return
      the converted sequence.

      = INPUT VARIABLES
      - value   The value or list of values that need to be converted.
      - unit    The units to use for a axis with Epoch data.

      = RETURN VALUE
      - Returns the value parameter converted to floats.
      """
      # Delay-load due to circular dependencies.
      import matplotlib.testing.jpl_units as U

      isNotUnitDbl = True

      if ( iterable(value) and not isinstance(value, six.string_types) ):
         if ( len(value) == 0 ):
            return []
         else:
            return [ UnitDblConverter.convert( x, unit, axis ) for x in value ]

      # We need to check to see if the incoming value is actually a UnitDbl and
      # set a flag.  If we get an empty list, then just return an empty list.
      if ( isinstance(value, U.UnitDbl) ):
         isNotUnitDbl = False

      # If the incoming value behaves like a number, but is not a UnitDbl,
      # then just return it because we don't know how to convert it
      # (or it is already converted)
      if ( isNotUnitDbl and units.ConversionInterface.is_numlike( value ) ):
         return value

      # If no units were specified, then get the default units to use.
      if ( unit == None ):
         unit = UnitDblConverter.default_units( value, axis )

      # Convert the incoming UnitDbl value/values to float/floats
      if isinstance( axis.axes, polar.PolarAxes ) and (value.type() == "angle"):
         # Guarantee that units are radians for polar plots.
         return value.convert( "rad" )

      return value.convert( unit )

   #------------------------------------------------------------------------ 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:47,代码来源:UnitDblConverter.py

示例8: convert

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def convert(value, unit, axis):
        """: Convert value using unit to a float.  If value is a sequence, return
        the converted sequence.

        = INPUT VARIABLES
        - value    The value or list of values that need to be converted.
        - unit     The units to use for a axis with Epoch data.

        = RETURN VALUE
        - Returns the value parameter converted to floats.
        """
        # Delay-load due to circular dependencies.
        import matplotlib.testing.jpl_units as U

        isNotUnitDbl = True

        if iterable(value) and not isinstance(value, str):
            if len(value) == 0:
                return []
            else:
                return [UnitDblConverter.convert(x, unit, axis) for x in value]

        # We need to check to see if the incoming value is actually a
        # UnitDbl and set a flag.  If we get an empty list, then just
        # return an empty list.
        if (isinstance(value, U.UnitDbl)):
            isNotUnitDbl = False

        # If the incoming value behaves like a number, but is not a UnitDbl,
        # then just return it because we don't know how to convert it
        # (or it is already converted)
        if (isNotUnitDbl and units.ConversionInterface.is_numlike(value)):
            return value

        # If no units were specified, then get the default units to use.
        if unit is None:
            unit = UnitDblConverter.default_units(value, axis)

        # Convert the incoming UnitDbl value/values to float/floats
        if isinstance(axis.axes, polar.PolarAxes) and value.type() == "angle":
            # Guarantee that units are radians for polar plots.
            return value.convert("rad")

        return value.convert(unit)

    # ----------------------------------------------------------------------- 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:48,代码来源:UnitDblConverter.py

示例9: test_as_mpl_axes_api

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def test_as_mpl_axes_api():
    # tests the _as_mpl_axes api
    from matplotlib.projections.polar import PolarAxes
    import matplotlib.axes as maxes

    class Polar(object):
        def __init__(self):
            self.theta_offset = 0

        def _as_mpl_axes(self):
            # implement the matplotlib axes interface
            return PolarAxes, {'theta_offset': self.theta_offset}

    prj = Polar()
    prj2 = Polar()
    prj2.theta_offset = np.pi
    prj3 = Polar()

    # testing axes creation with plt.axes
    ax = plt.axes([0, 0, 1, 1], projection=prj)
    assert type(ax) == PolarAxes
    ax_via_gca = plt.gca(projection=prj)
    assert ax_via_gca is ax
    plt.close()

    # testing axes creation with gca
    ax = plt.gca(projection=prj)
    assert type(ax) == maxes._subplots.subplot_class_factory(PolarAxes)
    ax_via_gca = plt.gca(projection=prj)
    assert ax_via_gca is ax
    # try getting the axes given a different polar projection
    with pytest.warns(UserWarning) as rec:
        ax_via_gca = plt.gca(projection=prj2)
        assert len(rec) == 1
        assert 'Requested projection is different' in str(rec[0].message)
    assert ax_via_gca is not ax
    assert ax.get_theta_offset() == 0
    assert ax_via_gca.get_theta_offset() == np.pi
    # try getting the axes given an == (not is) polar projection
    with pytest.warns(UserWarning):
        ax_via_gca = plt.gca(projection=prj3)
        assert len(rec) == 1
        assert 'Requested projection is different' in str(rec[0].message)
    assert ax_via_gca is ax
    plt.close()

    # testing axes creation with subplot
    ax = plt.subplot(121, projection=prj)
    assert type(ax) == maxes._subplots.subplot_class_factory(PolarAxes)
    plt.close() 
开发者ID:holzschu,项目名称:python3_ios,代码行数:52,代码来源:test_axes.py

示例10: convert

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def convert(value, unit, axis):
        """: Convert value using unit to a float.  If value is a sequence, return
        the converted sequence.

        = INPUT VARIABLES
        - value    The value or list of values that need to be converted.
        - unit     The units to use for a axis with Epoch data.

        = RETURN VALUE
        - Returns the value parameter converted to floats.
        """
        # Delay-load due to circular dependencies.
        import matplotlib.testing.jpl_units as U

        isNotUnitDbl = True

        if np.iterable(value) and not isinstance(value, str):
            if len(value) == 0:
                return []
            else:
                return [UnitDblConverter.convert(x, unit, axis) for x in value]

        # We need to check to see if the incoming value is actually a
        # UnitDbl and set a flag.  If we get an empty list, then just
        # return an empty list.
        if isinstance(value, U.UnitDbl):
            isNotUnitDbl = False

        # If the incoming value behaves like a number, but is not a UnitDbl,
        # then just return it because we don't know how to convert it
        # (or it is already converted)
        if isNotUnitDbl and units.ConversionInterface.is_numlike(value):
            return value

        # If no units were specified, then get the default units to use.
        if unit is None:
            unit = UnitDblConverter.default_units(value, axis)

        # Convert the incoming UnitDbl value/values to float/floats
        if isinstance(axis.axes, polar.PolarAxes) and value.type() == "angle":
            # Guarantee that units are radians for polar plots.
            return value.convert("rad")

        return value.convert(unit) 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:46,代码来源:UnitDblConverter.py

示例11: test_as_mpl_axes_api

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def test_as_mpl_axes_api():
    # tests the _as_mpl_axes api
    from matplotlib.projections.polar import PolarAxes
    import matplotlib.axes as maxes

    class Polar(object):
        def __init__(self):
            self.theta_offset = 0

        def _as_mpl_axes(self):
            # implement the matplotlib axes interface
            return PolarAxes, {'theta_offset': self.theta_offset}
    prj = Polar()
    prj2 = Polar()
    prj2.theta_offset = np.pi
    prj3 = Polar()

    # testing axes creation with plt.axes
    ax = plt.axes([0, 0, 1, 1], projection=prj)
    assert type(ax) == PolarAxes
    ax_via_gca = plt.gca(projection=prj)
    assert ax_via_gca is ax
    plt.close()

    # testing axes creation with gca
    ax = plt.gca(projection=prj)
    assert type(ax) == maxes._subplots._subplot_classes[PolarAxes]
    ax_via_gca = plt.gca(projection=prj)
    assert ax_via_gca is ax
    # try getting the axes given a different polar projection
    with pytest.warns(UserWarning) as rec:
        ax_via_gca = plt.gca(projection=prj2)
        assert len(rec) == 1
        assert 'Requested projection is different' in str(rec[0].message)
    assert ax_via_gca is not ax
    assert ax.get_theta_offset() == 0
    assert ax_via_gca.get_theta_offset() == np.pi
    # try getting the axes given an == (not is) polar projection
    with pytest.warns(UserWarning):
        ax_via_gca = plt.gca(projection=prj3)
        assert len(rec) == 1
        assert 'Requested projection is different' in str(rec[0].message)
    assert ax_via_gca is ax
    plt.close()

    # testing axes creation with subplot
    ax = plt.subplot(121, projection=prj)
    assert type(ax) == maxes._subplots._subplot_classes[PolarAxes]
    plt.close() 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:51,代码来源:test_axes.py

示例12: convert

# 需要导入模块: from matplotlib.projections import polar [as 别名]
# 或者: from matplotlib.projections.polar import PolarAxes [as 别名]
def convert( value, unit, axis ):
      """: Convert value using unit to a float.  If value is a sequence, return
      the converted sequence.

      = INPUT VARIABLES
      - value   The value or list of values that need to be converted.
      - unit    The units to use for a axis with Epoch data.

      = RETURN VALUE
      - Returns the value parameter converted to floats.
      """
      # Delay-load due to circular dependencies.
      import matplotlib.testing.jpl_units as U

      isNotUnitDbl = True

      if ( iterable(value) and not isinstance(value, six.string_types) ):
         if ( len(value) == 0 ):
            return []
         else:
            return [ UnitDblConverter.convert( x, unit, axis ) for x in value ]

      # We need to check to see if the incoming value is actually a UnitDbl and
      # set a flag.  If we get an empty list, then just return an empty list.
      if ( isinstance(value, U.UnitDbl) ):
         isNotUnitDbl = False

      # If the incoming value behaves like a number, but is not a UnitDbl,
      # then just return it because we don't know how to convert it
      # (or it is already converted)
      if ( isNotUnitDbl and units.ConversionInterface.is_numlike( value ) ):
         return value

      # If no units were specified, then get the default units to use.
      if ( unit == None ):
         unit = UnitDblConverter.default_units( value, axis )

      # Convert the incoming UnitDbl value/values to float/floats
      if isinstance( axis.axes, polar.PolarAxes ) and value.type() == "angle":
         # Guarantee that units are radians for polar plots.
         return value.convert( "rad" )

      return value.convert( unit )

   #------------------------------------------------------------------------ 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:47,代码来源:UnitDblConverter.py


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