本文整理汇总了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 )
#------------------------------------------------------------------------
示例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 )
#------------------------------------------------------------------------
示例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)
# -----------------------------------------------------------------------
示例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)
示例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 )
#------------------------------------------------------------------------
示例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()
示例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 )
#------------------------------------------------------------------------
示例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)
# -----------------------------------------------------------------------
示例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()
示例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)
示例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()
示例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 )
#------------------------------------------------------------------------