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


Python ticker.FixedLocator方法代码示例

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


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

示例1: set_ticks

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def set_ticks(self, ticks, minor=False):
        """
        Set the locations of the tick marks from sequence ticks

        ACCEPTS: sequence of floats
        """
        ### XXX if the user changes units, the information will be lost here
        ticks = self.convert_units(ticks)
        if len(ticks) > 1:
            xleft, xright = self.get_view_interval()
            if xright > xleft:
                self.set_view_interval(min(ticks), max(ticks))
            else:
                self.set_view_interval(max(ticks), min(ticks))
        if minor:
            self.set_minor_locator(mticker.FixedLocator(ticks))
            return self.get_minor_ticks(len(ticks))
        else:
            self.set_major_locator(mticker.FixedLocator(ticks))
            return self.get_major_ticks(len(ticks)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:axis.py

示例2: __init__

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def __init__(self, ax, mappable, **kw):
        mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
                             # are set when colorbar is called,
                             # even if mappable.draw has not yet
                             # been called.  This will not change
                             # vmin, vmax if they are already set.
        self.mappable = mappable
        kw['cmap'] = mappable.cmap
        kw['norm'] = mappable.norm
        kw['alpha'] = mappable.get_alpha()
        if isinstance(mappable, contour.ContourSet):
            CS = mappable
            kw['boundaries'] = CS._levels
            kw['values'] = CS.cvalues
            kw['extend'] = CS.extend
            #kw['ticks'] = CS._levels
            kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10))
            kw['filled'] = CS.filled
            ColorbarBase.__init__(self, ax, **kw)
            if not CS.filled:
                self.add_lines(CS)
        else:
            ColorbarBase.__init__(self, ax, **kw) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:colorbar.py

示例3: _select_locator

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def _select_locator(self, formatter):
        '''
        select a suitable locator
        '''
        if self.boundaries is None:
            if isinstance(self.norm, colors.NoNorm):
                nv = len(self._values)
                base = 1 + int(nv/10)
                locator = ticker.IndexLocator(base=base, offset=0)
            elif isinstance(self.norm, colors.BoundaryNorm):
                b = self.norm.boundaries
                locator = ticker.FixedLocator(b, nbins=10)
            elif isinstance(self.norm, colors.LogNorm):
                locator = ticker.LogLocator()
            else:
                locator = ticker.MaxNLocator(nbins=5)
        else:
            b = self._boundaries[self._inside]
            locator = ticker.FixedLocator(b) #, nbins=10)

        self.cbar_axis.set_major_locator(locator) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:colorbar.py

示例4: set_ticks

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def set_ticks(self, ticks, update_ticks=True):
        """
        Set tick locations.

        Parameters
        ----------
        ticks : {None, sequence, :class:`~matplotlib.ticker.Locator` instance}
            If None, a default Locator will be used.

        update_ticks : {True, False}, optional
            If True, tick locations are updated immediately.  If False,
            use :meth:`update_ticks` to manually update the ticks.

        """
        if np.iterable(ticks):
            self.locator = ticker.FixedLocator(ticks, nbins=len(ticks))
        else:
            self.locator = ticks

        if update_ticks:
            self.update_ticks()
        self.stale = True 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:24,代码来源:colorbar.py

示例5: set_ticks

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def set_ticks(self, ticks, minor=False):
        """
        Set the locations of the tick marks from sequence ticks

        Parameters
        ----------
        ticks : sequence of floats
        minor : bool
        """
        # XXX if the user changes units, the information will be lost here
        ticks = self.convert_units(ticks)
        if len(ticks) > 1:
            xleft, xright = self.get_view_interval()
            if xright > xleft:
                self.set_view_interval(min(ticks), max(ticks))
            else:
                self.set_view_interval(max(ticks), min(ticks))
        if minor:
            self.set_minor_locator(mticker.FixedLocator(ticks))
            return self.get_minor_ticks(len(ticks))
        else:
            self.set_major_locator(mticker.FixedLocator(ticks))
            return self.get_major_ticks(len(ticks)) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:25,代码来源:axis.py

示例6: set_ticks

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def set_ticks(self, ticks, update_ticks=True):
        """
        Set tick locations.

        Parameters
        ----------
        ticks : {None, sequence, :class:`~matplotlib.ticker.Locator` instance}
            If None, a default Locator will be used.

        update_ticks : {True, False}, optional
            If True, tick locations are updated immediately.  If False,
            use :meth:`update_ticks` to manually update the ticks.

        """
        if cbook.iterable(ticks):
            self.locator = ticker.FixedLocator(ticks, nbins=len(ticks))
        else:
            self.locator = ticks

        if update_ticks:
            self.update_ticks()
        self.stale = True 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:24,代码来源:colorbar.py

示例7: set_ticks

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def set_ticks(self, ticks, minor=False):
        """
        Set the locations of the tick marks from sequence ticks

        ACCEPTS: sequence of floats
        """
        # XXX if the user changes units, the information will be lost here
        ticks = self.convert_units(ticks)
        if len(ticks) > 1:
            xleft, xright = self.get_view_interval()
            if xright > xleft:
                self.set_view_interval(min(ticks), max(ticks))
            else:
                self.set_view_interval(max(ticks), min(ticks))
        if minor:
            self.set_minor_locator(mticker.FixedLocator(ticks))
            return self.get_minor_ticks(len(ticks))
        else:
            self.set_major_locator(mticker.FixedLocator(ticks))
            return self.get_major_ticks(len(ticks)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:22,代码来源:axis.py

示例8: set_default_locators_and_formatters

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def set_default_locators_and_formatters(self, axis):
        """
        Override to set up the locators and formatters to use with the
        scale.  This is only required if the scale requires custom
        locators and formatters.  Writing custom locators and
        formatters is rather outside the scope of this example, but
        there are many helpful examples in ``ticker.py``.

        In our case, the Mercator example uses a fixed locator from
        -90 to 90 degrees and a custom formatter class to put convert
        the radians to degrees and put a degree symbol after the
        value::
        """
        class DegreeFormatter(Formatter):
            def __call__(self, x, pos=None):
                return "%d\N{DEGREE SIGN}" % np.degrees(x)

        axis.set_major_locator(FixedLocator(
            np.radians(np.arange(-90, 90, 10))))
        axis.set_major_formatter(DegreeFormatter())
        axis.set_minor_formatter(DegreeFormatter()) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:23,代码来源:custom_scale.py

示例9: __init__

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def __init__(self, ax, mappable, **kw):
        # Ensure mappable.norm.vmin, vmax are set when colorbar is called, even
        # if mappable.draw has not yet been called. This will not change vmin,
        # vmax if they are already set.
        mappable.autoscale_None()

        self.mappable = mappable
        kw['cmap'] = mappable.cmap
        kw['norm'] = mappable.norm
        kw['alpha'] = mappable.get_alpha()
        if isinstance(mappable, contour.ContourSet):
            CS = mappable
            kw['boundaries'] = CS._levels
            kw['values'] = CS.cvalues
            kw['extend'] = CS.extend
            #kw['ticks'] = CS._levels
            kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10))
            kw['filled'] = CS.filled
            ColorbarBase.__init__(self, ax, **kw)
            if not CS.filled:
                self.add_lines(CS)
        else:
            ColorbarBase.__init__(self, ax, **kw) 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:25,代码来源:colorbar.py

示例10: set_ticks

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def set_ticks(self, ticks, update_ticks=True):
        """
        set tick locations. Tick locations are updated immediately unless
        update_ticks is *False*. To manually update the ticks, call
        *update_ticks* method explicitly.
        """
        if cbook.iterable(ticks):
            self.locator = ticker.FixedLocator(ticks, nbins=len(ticks))
        else:
            self.locator = ticks

        if update_ticks:
            self.update_ticks() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:colorbar.py

示例11: set_ticklabels

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def set_ticklabels(self, ticklabels, update_ticks=True):
        """
        set tick labels. Tick labels are updated immediately unless
        update_ticks is *False*. To manually update the ticks, call
        *update_ticks* method explicitly.
        """
        if isinstance(self.locator, ticker.FixedLocator):
            self.formatter = ticker.FixedFormatter(ticklabels)
            if update_ticks:
                self.update_ticks()
        else:
            warnings.warn("set_ticks() must have been called.") 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:14,代码来源:colorbar.py

示例12: __init__

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def __init__(self, ax, mappable, **kw):
        # Ensure the given mappable's norm has appropriate vmin and vmax set
        # even if mappable.draw has not yet been called.
        mappable.autoscale_None()

        self.mappable = mappable
        kw['cmap'] = cmap = mappable.cmap
        kw['norm'] = norm = mappable.norm

        if isinstance(mappable, contour.ContourSet):
            CS = mappable
            kw['alpha'] = mappable.get_alpha()
            kw['boundaries'] = CS._levels
            kw['values'] = CS.cvalues
            kw['extend'] = CS.extend
            #kw['ticks'] = CS._levels
            kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10))
            kw['filled'] = CS.filled
            ColorbarBase.__init__(self, ax, **kw)
            if not CS.filled:
                self.add_lines(CS)
        else:
            if getattr(cmap, 'colorbar_extend', False) is not False:
                kw.setdefault('extend', cmap.colorbar_extend)

            if isinstance(mappable, martist.Artist):
                kw['alpha'] = mappable.get_alpha()

            ColorbarBase.__init__(self, ax, **kw) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:31,代码来源:colorbar.py

示例13: _plotStats

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def _plotStats(self, df, strategyName):
        """
            绘制账户盈亏统计图
        """
        def _dateFormatter(x, pos):
            if not (0 <= int(x) < df.shape[0]):
                return None

            return df.index[int(x)].strftime("%y-%m-%d")

        # create grid spec
        gs = GridSpec(4, 1)
        gs.update(hspace=0)

        # subplot for PnL
        axPnl = plt.subplot(gs[:-1, :])
        axPnl.grid(True)
        axPnl.set_title('{}: 盈亏(%)'.format(strategyName))

        # set x ticks
        x = [x for x in range(df.shape[0])]
        xspace = max((len(x)+9)//10, 1)
        axPnl.xaxis.set_major_locator(FixedLocator(x[:-xspace-1: xspace] + x[-1:]))
        axPnl.xaxis.set_major_formatter(FuncFormatter(_dateFormatter))

        # plot pnl
        for name in df.columns:
            if name not in ['持仓资金(%)', '持仓股票数']:
                axPnl.plot(x, df[name].values, label=name)

        axPnl.legend(loc='upper left', frameon=False)

        # subplot for position
        axPos = plt.subplot(gs[-1, :], sharex=axPnl)
        axPos.grid(True)
        axPos.bar(x, df['持仓资金(%)'].values, label='持仓资金(%)')
        axPos.plot(x, df['持仓资金(%)'].values.cumsum()/np.array(list(range(1, df.shape[0] + 1))), label='平均持仓资金(%)', color='g')
        axPos.plot(x, df['持仓股票数'].values, label='持仓股票数', color='r')

        axPos.legend(loc='upper left', frameon=False) 
开发者ID:moyuanz,项目名称:DevilYuan,代码行数:42,代码来源:DyStockBackTestingStrategyResultStatsWidget.py

示例14: set_ticklabels

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def set_ticklabels(self, ticklabels, update_ticks=True):
        """
        Set tick labels.

        Tick labels are updated immediately unless *update_ticks* is *False*,
        in which case one should call `.update_ticks` explicitly.
        """
        if isinstance(self.locator, ticker.FixedLocator):
            self.formatter = ticker.FixedFormatter(ticklabels)
            if update_ticks:
                self.update_ticks()
        else:
            cbook._warn_external("set_ticks() must have been called.")
        self.stale = True 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:16,代码来源:colorbar.py

示例15: __init__

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FixedLocator [as 别名]
def __init__(self, ax, mappable, **kw):
        # Ensure the given mappable's norm has appropriate vmin and vmax set
        # even if mappable.draw has not yet been called.
        if mappable.get_array() is not None:
            mappable.autoscale_None()

        self.mappable = mappable
        kw['cmap'] = cmap = mappable.cmap
        kw['norm'] = mappable.norm

        if isinstance(mappable, contour.ContourSet):
            CS = mappable
            kw['alpha'] = mappable.get_alpha()
            kw['boundaries'] = CS._levels
            kw['values'] = CS.cvalues
            kw['extend'] = CS.extend
            kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10))
            kw['filled'] = CS.filled
            ColorbarBase.__init__(self, ax, **kw)
            if not CS.filled:
                self.add_lines(CS)
        else:
            if getattr(cmap, 'colorbar_extend', False) is not False:
                kw.setdefault('extend', cmap.colorbar_extend)

            if isinstance(mappable, martist.Artist):
                kw['alpha'] = mappable.get_alpha()

            ColorbarBase.__init__(self, ax, **kw) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:31,代码来源:colorbar.py


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