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


Python ticker.Locator方法代码示例

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


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

示例1: set_major_locator

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import Locator [as 别名]
def set_major_locator(self, locator):
        """
        Set the locator of the major ticker.

        Parameters
        ----------
        locator : ~matplotlib.ticker.Locator
        """
        if not isinstance(locator, mticker.Locator):
            raise TypeError("locator argument should be instance of "
                            "matplotlib.ticker.Locator")
        self.isDefault_majloc = False
        self.major.locator = locator
        if self.major.formatter:
            self.major.formatter._set_locator(locator)
        locator.set_axis(self)
        self.stale = True 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:19,代码来源:axis.py

示例2: set_minor_locator

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import Locator [as 别名]
def set_minor_locator(self, locator):
        """
        Set the locator of the minor ticker.

        Parameters
        ----------
        locator : ~matplotlib.ticker.Locator
        """
        if not isinstance(locator, mticker.Locator):
            raise TypeError("locator argument should be instance of "
                            "matplotlib.ticker.Locator")
        self.isDefault_minloc = False
        self.minor.locator = locator
        if self.minor.formatter:
            self.minor.formatter._set_locator(locator)
        locator.set_axis(self)
        self.stale = True 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:19,代码来源:axis.py

示例3: set_major_locator

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import Locator [as 别名]
def set_major_locator(self, locator):
        """
        Set the locator of the major ticker.

        Parameters
        ----------
        locator : `~matplotlib.ticker.Locator`
        """
        if not isinstance(locator, mticker.Locator):
            raise TypeError("locator argument should be instance of "
                            "matplotlib.ticker.Locator")
        self.isDefault_majloc = False
        self.major.locator = locator
        if self.major.formatter:
            self.major.formatter._set_locator(locator)
        locator.set_axis(self)
        self.stale = True 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:19,代码来源:axis.py

示例4: set_minor_locator

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import Locator [as 别名]
def set_minor_locator(self, locator):
        """
        Set the locator of the minor ticker.

        Parameters
        ----------
        locator : `~matplotlib.ticker.Locator`
        """
        if not isinstance(locator, mticker.Locator):
            raise TypeError("locator argument should be instance of "
                            "matplotlib.ticker.Locator")
        self.isDefault_minloc = False
        self.minor.locator = locator
        if self.minor.formatter:
            self.minor.formatter._set_locator(locator)
        locator.set_axis(self)
        self.stale = True 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:19,代码来源:axis.py

示例5: set_major_locator

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import Locator [as 别名]
def set_major_locator(self, locator):
        """
        Set the locator of the major ticker.

        Parameters
        ----------
        locator : ~matplotlib.ticker.Locator
        """
        if not isinstance(locator, mticker.Locator):
            raise TypeError("formatter argument should be instance of "
                    "matplotlib.ticker.Locator")
        self.isDefault_majloc = False
        self.major.locator = locator
        locator.set_axis(self)
        self.stale = True 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:17,代码来源:axis.py

示例6: set_minor_locator

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import Locator [as 别名]
def set_minor_locator(self, locator):
        """
        Set the locator of the minor ticker.

        Parameters
        ----------
        locator : ~matplotlib.ticker.Locator
        """
        if not isinstance(locator, mticker.Locator):
            raise TypeError("formatter argument should be instance of "
                    "matplotlib.ticker.Locator")
        self.isDefault_minloc = False
        self.minor.locator = locator
        locator.set_axis(self)
        self.stale = True 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:17,代码来源:axis.py

示例7: _set_axis_ticks

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import Locator [as 别名]
def _set_axis_ticks(self, axis, ticks, log=False, rotation=0):
        """
        Allows setting the ticks for a particular axis either with
        a tuple of ticks, a tick locator object, an integer number
        of ticks, a list of tuples containing positions and labels
        or a list of positions. Also supports enabling log ticking
        if an integer number of ticks is supplied and setting a
        rotation for the ticks.
        """
        if isinstance(ticks, (list, tuple)) and all(isinstance(l, list) for l in ticks):
            axis.set_ticks(ticks[0])
            axis.set_ticklabels(ticks[1])
        elif isinstance(ticks, ticker.Locator):
            axis.set_major_locator(ticks)
        elif not ticks and ticks is not None:
            axis.set_ticks([])
        elif isinstance(ticks, int):
            if log:
                locator = ticker.LogLocator(numticks=ticks,
                                            subs=range(1,10))
            else:
                locator = ticker.MaxNLocator(ticks)
            axis.set_major_locator(locator)
        elif isinstance(ticks, (list, tuple)):
            labels = None
            if all(isinstance(t, tuple) for t in ticks):
                ticks, labels = zip(*ticks)
            axis.set_ticks(ticks)
            if labels:
                axis.set_ticklabels(labels)
        for tick in axis.get_ticklabels():
            tick.set_rotation(rotation) 
开发者ID:holoviz,项目名称:holoviews,代码行数:34,代码来源:element.py

示例8: _adjust_cbar

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import Locator [as 别名]
def _adjust_cbar(self, cbar, label, dim):
        noalpha = math.floor(self.style[self.cyclic_index].get('alpha', 1)) == 1

        for lb in ['clabel', 'labels']:
            labelsize = self._fontsize(lb, common=False).get('fontsize')
            if labelsize is not None:
                break

        if (cbar.solids and noalpha):
            cbar.solids.set_edgecolor("face")
        cbar.set_label(label, fontsize=labelsize)
        if isinstance(self.cbar_ticks, ticker.Locator):
            cbar.ax.yaxis.set_major_locator(self.cbar_ticks)
        elif self.cbar_ticks == 0:
            cbar.set_ticks([])
        elif isinstance(self.cbar_ticks, int):
            locator = ticker.MaxNLocator(self.cbar_ticks)
            cbar.ax.yaxis.set_major_locator(locator)
        elif isinstance(self.cbar_ticks, list):
            if all(isinstance(t, tuple) for t in self.cbar_ticks):
                ticks, labels = zip(*self.cbar_ticks)
            else:
                ticks, labels = zip(*[(t, dim.pprint_value(t))
                                        for t in self.cbar_ticks])
            cbar.set_ticks(ticks)
            cbar.set_ticklabels(labels)

        for tk in ['cticks', 'ticks']:
            ticksize = self._fontsize(tk, common=False).get('fontsize')
            if ticksize is not None:
                cbar.ax.tick_params(labelsize=ticksize)
                break 
开发者ID:holoviz,项目名称:holoviews,代码行数:34,代码来源:element.py

示例9: __call__

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import Locator [as 别名]
def __call__(self):
        # if no data have been set, this will tank with a ValueError
        try:
            dmin, dmax = self.viewlim_to_dt()
        except ValueError:
            return []

        if dmin > dmax:
            dmax, dmin = dmin, dmax
        delta = relativedelta(dmax, dmin)

        # We need to cap at the endpoints of valid datetime
        try:
            start = dmin - delta
        except ValueError:
            start = _from_ordinalf(1.0)

        try:
            stop = dmax + delta
        except ValueError:
            # The magic number!
            stop = _from_ordinalf(3652059.9999999)

        self.rule.set(dtstart=start, until=stop, count=self.MAXTICKS + 1)

        # estimate the number of ticks very approximately so we don't
        # have to do a very expensive (and potentially near infinite)
        # 'between' calculation, only to find out it will fail.
        nmax, nmin = date2num((dmax, dmin))
        estimate = (nmax - nmin) / (self._get_unit() * self._get_interval())
        # This estimate is only an estimate, so be really conservative
        # about bailing...
        if estimate > self.MAXTICKS * 2:
            raise RuntimeError(
                'RRuleLocator estimated to generate %d ticks from %s to %s: '
                'exceeds Locator.MAXTICKS * 2 (%d) ' % (estimate, dmin, dmax,
                                                        self.MAXTICKS * 2))

        dates = self.rule.between(dmin, dmax, True)
        if len(dates) == 0:
            return date2num([dmin, dmax])
        return self.raise_if_exceeds(date2num(dates)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:44,代码来源:dates.py


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