本文整理匯總了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