本文整理汇总了Python中matplotlib.units方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib.units方法的具体用法?Python matplotlib.units怎么用?Python matplotlib.units使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib
的用法示例。
在下文中一共展示了matplotlib.units方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: axisinfo
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import units [as 别名]
def axisinfo(unit, axis):
"""
Return the :class:`~matplotlib.units.AxisInfo` for *unit*.
*unit* is a tzinfo instance or None.
The *axis* argument is required but not used.
"""
tz = unit
majloc = AutoDateLocator(tz=tz)
majfmt = AutoDateFormatter(majloc, tz=tz)
datemin = datetime.date(2000, 1, 1)
datemax = datetime.date(2010, 1, 1)
return units.AxisInfo(majloc=majloc, majfmt=majfmt, label='',
default_limits=(datemin, datemax))
示例2: _get_interval
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import units [as 别名]
def _get_interval(self):
"""
Return the number of units for each tick.
"""
return 1
示例3: convert
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import units [as 别名]
def convert(value, unit, axis):
"""
If *value* is not already a number or sequence of numbers,
convert it with :func:`date2num`.
The *unit* and *axis* arguments are not used.
"""
if units.ConversionInterface.is_numlike(value):
return value
return date2num(value)
示例4: setup_class
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import units [as 别名]
def setup_class(cls):
cls.original_units_registry = matplotlib.units.registry.copy()
示例5: datalim_to_dt
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import units [as 别名]
def datalim_to_dt(self):
"""
Convert axis data interval to datetime objects.
"""
dmin, dmax = self.axis.get_data_interval()
if dmin > dmax:
dmin, dmax = dmax, dmin
if dmin < 1:
raise ValueError('datalim minimum {} is less than 1 and '
'is an invalid Matplotlib date value. This often '
'happens if you pass a non-datetime '
'value to an axis that has datetime units'
.format(dmin))
return num2date(dmin, self.tz), num2date(dmax, self.tz)
示例6: viewlim_to_dt
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import units [as 别名]
def viewlim_to_dt(self):
"""
Converts the view interval to datetime objects.
"""
vmin, vmax = self.axis.get_view_interval()
if vmin > vmax:
vmin, vmax = vmax, vmin
if vmin < 1:
raise ValueError('view limit minimum {} is less than 1 and '
'is an invalid Matplotlib date value. This '
'often happens if you pass a non-datetime '
'value to an axis that has datetime units'
.format(vmin))
return num2date(vmin, self.tz), num2date(vmax, self.tz)
示例7: units
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import units [as 别名]
def units(self):
if self._units is None:
try:
from astropy import units
self.log
except ImportError:
units = NotAModule(self._name)
self._units = units
return self._units