Python matplotlib.units() Examples

The following are 30 code examples of matplotlib.units(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module matplotlib , or try the search function .
Example #1
Source File: dates.py    From neural-network-animation with MIT License 6 votes vote down vote up
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)) 
Example #2
Source File: dates.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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)) 
Example #3
Source File: dates.py    From GraphicDesignPatternByPython with MIT License 6 votes vote down vote up
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)) 
Example #4
Source File: dates.py    From coffeegrindsize with MIT License 6 votes vote down vote up
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)) 
Example #5
Source File: dates.py    From CogAlg with MIT License 6 votes vote down vote up
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)) 
Example #6
Source File: dates.py    From matplotlib-4-abaqus with MIT License 6 votes vote down vote up
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)) 
Example #7
Source File: dates.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
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)) 
Example #8
Source File: dates.py    From Computable with MIT License 6 votes vote down vote up
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)) 
Example #9
Source File: dates.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def _get_interval(self):
        """
        Return the number of units for each tick.
        """
        return self._interval 
Example #10
Source File: _on_demand_imports.py    From unyt with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 
Example #11
Source File: _on_demand_imports.py    From unyt with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def units(self):
        if self._units is None:
            try:
                from matplotlib import units
            except ImportError:
                units = NotAModule(self._name)
            self._units = units
        return self._units 
Example #12
Source File: dates.py    From coffeegrindsize with MIT License 5 votes vote down vote up
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) 
Example #13
Source File: dates.py    From coffeegrindsize with MIT License 5 votes vote down vote up
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) 
Example #14
Source File: dates.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def _get_interval(self):
        """
        Return the number of units for each tick.
        """
        return 1 
Example #15
Source File: dates.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def _get_interval(self):
        """
        Return the number of units for each tick.
        """
        return self._interval 
Example #16
Source File: dates.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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) 
Example #17
Source File: dates.py    From CogAlg with MIT License 5 votes vote down vote up
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) 
Example #18
Source File: dates.py    From CogAlg with MIT License 5 votes vote down vote up
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) 
Example #19
Source File: dates.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _get_interval(self):
        """
        Return the number of units for each tick.
        """
        return 1 
Example #20
Source File: dates.py    From CogAlg with MIT License 5 votes vote down vote up
def _get_interval(self):
        """
        Return the number of units for each tick.
        """
        return 1 
Example #21
Source File: dates.py    From CogAlg with MIT License 5 votes vote down vote up
def _get_interval(self):
        """
        Return the number of units for each tick.
        """
        return self._interval 
Example #22
Source File: dates.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def _get_interval(self):
        """
        Return the number of units for each tick.
        """
        return 1 
Example #23
Source File: dates.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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) 
Example #24
Source File: dates.py    From neural-network-animation with MIT License 5 votes vote down vote up
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) 
Example #25
Source File: dates.py    From Computable with MIT License 5 votes vote down vote up
def _get_interval(self):
        """
        Return the number of units for each tick.
        """
        return self._interval 
Example #26
Source File: dates.py    From Computable with MIT License 5 votes vote down vote up
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) 
Example #27
Source File: dates.py    From matplotlib-4-abaqus with MIT License 5 votes vote down vote up
def _get_interval(self):
        """
        Return the number of units for each tick.
        """
        return 1 
Example #28
Source File: dates.py    From matplotlib-4-abaqus with MIT License 5 votes vote down vote up
def _get_interval(self):
        """
        Return the number of units for each tick.
        """
        return self._interval 
Example #29
Source File: dates.py    From matplotlib-4-abaqus with MIT License 5 votes vote down vote up
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) 
Example #30
Source File: decorators.py    From matplotlib-4-abaqus with MIT License 5 votes vote down vote up
def setup_class(cls):
        cls.original_units_registry = matplotlib.units.registry.copy()