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


Python ticker.IndexLocator方法代码示例

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


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

示例1: _select_locator

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import IndexLocator [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

示例2: _select_locator

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import IndexLocator [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)

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

示例3: plot_activation

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import IndexLocator [as 别名]
def plot_activation(matrix, step, save_to=None):
    save_to = os.path.join(".", "activations") if save_to is None else save_to
    os.makedirs(save_to, exist_ok=True)
    if len(matrix.shape) != 2:
        raise ValueError('Input "matrix" should have 2 rank, but it is',str(len(matrix.shape)))
    num_label = matrix.shape[1] - 1
    matrix = matrix[matrix[:, num_label].argsort()]
    fig, axes = plt.subplots(ncols=1, nrows=num_label, figsize=(15,12))
    fig.suptitle("The probability of entity presence (step %s)"%str(step), fontsize=20)
    fig.tight_layout()
    for i, ax in enumerate(axes.flatten()):
        idx = num_label - (i + 1)
        ax.spines['top'].set_color('none')
        ax.spines['bottom'].set_color('none')
        ax.set_ylim(0, 1.05)
        ax.set_ylabel("Capsule " + str(idx))
        ax.yaxis.set_major_locator(ticker.NullLocator())
        if idx > 0:
            ax.xaxis.set_major_locator(ticker.NullLocator())
        else:
            ax.xaxis.set_major_locator(ticker.IndexLocator(base=500,offset=0))
            ax.set_xlabel("Sample index ")
        ax.plot(matrix[:,idx])
        ax_prime = ax.twinx()
        ax_prime.spines['top'].set_color('none')
        ax_prime.spines['bottom'].set_color('none')
    plt.subplots_adjust(hspace=0.2, left=0.05, right=0.95, bottom=0.05, top=.95)
    plt.savefig(os.path.join(save_to, "activation_%s.png" % str(step)))
    plt.close() 
开发者ID:naturomics,项目名称:CapsLayer,代码行数:31,代码来源:figure.py

示例4: _get_ticker_locator_formatter

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import IndexLocator [as 别名]
def _get_ticker_locator_formatter(self):
        """
        This code looks at the norm being used by the colorbar
        and decides what locator and formatter to use.  If ``locator`` has
        already been set by hand, it just returns
        ``self.locator, self.formatter``.
        """
        locator = self.locator
        formatter = self.formatter
        if locator is None:
            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 = _ColorbarLogLocator(self)
                elif isinstance(self.norm, colors.SymLogNorm):
                    # The subs setting here should be replaced
                    # by logic in the locator.
                    locator = ticker.SymmetricalLogLocator(
                                      subs=np.arange(1, 10),
                                      linthresh=self.norm.linthresh,
                                      base=10)
                else:
                    if mpl.rcParams['_internal.classic_mode']:
                        locator = ticker.MaxNLocator()
                    else:
                        locator = _ColorbarAutoLocator(self)
            else:
                b = self._boundaries[self._inside]
                locator = ticker.FixedLocator(b, nbins=10)
        _log.debug('locator: %r', locator)
        return locator, formatter 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:39,代码来源:colorbar.py

示例5: axisinfo

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import IndexLocator [as 别名]
def axisinfo(unit, axis):
        'return the Foo AxisInfo'
        if unit == 1.0 or unit == 2.0:
            return units.AxisInfo(
                majloc=ticker.IndexLocator(8, 0),
                majfmt=ticker.FormatStrFormatter("VAL: %s"),
                label='foo',
                )

        else:
            return None 
开发者ID:holzschu,项目名称:python3_ios,代码行数:13,代码来源:evans_test.py

示例6: test_set_params

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import IndexLocator [as 别名]
def test_set_params(self):
        """
        Create index locator with 3 base, 4 offset. and change it to something
        else. See if change was successful.
        Should not exception.
        """
        index = mticker.IndexLocator(base=3, offset=4)
        index.set_params(base=7, offset=7)
        assert index._base == 7
        assert index.offset == 7 
开发者ID:holzschu,项目名称:python3_ios,代码行数:12,代码来源:test_ticker.py

示例7: _ticker

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import IndexLocator [as 别名]
def _ticker(self):
        '''
        Return two sequences: ticks (colorbar data locations)
        and ticklabels (strings).
        '''
        locator = self.locator
        formatter = self.formatter
        if locator is None:
            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()
            else:
                b = self._boundaries[self._inside]
                locator = ticker.FixedLocator(b, nbins=10)
        if isinstance(self.norm, colors.NoNorm):
            intv = self._values[0], self._values[-1]
        else:
            intv = self.vmin, self.vmax
        locator.create_dummy_axis(minpos=intv[0])
        formatter.create_dummy_axis(minpos=intv[0])
        locator.set_view_interval(*intv)
        locator.set_data_interval(*intv)
        formatter.set_view_interval(*intv)
        formatter.set_data_interval(*intv)

        b = np.array(locator())
        ticks = self._locate(b)
        inrange = (ticks > -0.001) & (ticks < 1.001)
        ticks = ticks[inrange]
        b = b[inrange]
        formatter.set_locs(b)
        ticklabels = [formatter(t, i) for i, t in enumerate(b)]
        offset_string = formatter.get_offset()
        return ticks, ticklabels, offset_string 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:45,代码来源:colorbar.py

示例8: _get_ticker_locator_formatter

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import IndexLocator [as 别名]
def _get_ticker_locator_formatter(self):
        """
        This code looks at the norm being used by the colorbar
        and decides what locator and formatter to use.  If ``locator`` has
        already been set by hand, it just returns
        ``self.locator, self.formatter``.
        """
        locator = self.locator
        formatter = self.formatter
        if locator is None:
            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 = _ColorbarLogLocator(self)
                elif isinstance(self.norm, colors.SymLogNorm):
                    # The subs setting here should be replaced
                    # by logic in the locator.
                    locator = ticker.SymmetricalLogLocator(
                                      subs=np.arange(1, 10),
                                      linthresh=self.norm.linthresh,
                                      base=10)
                else:
                    if mpl.rcParams['_internal.classic_mode']:
                        locator = ticker.MaxNLocator()
                    else:
                        locator = _ColorbarAutoLocator(self)
            else:
                b = self._boundaries[self._inside]
                locator = ticker.FixedLocator(b, nbins=10)

        if formatter is None:
            if isinstance(self.norm, colors.LogNorm):
                formatter = ticker.LogFormatterSciNotation()
            elif isinstance(self.norm, colors.SymLogNorm):
                formatter = ticker.LogFormatterSciNotation(
                                        linthresh=self.norm.linthresh)
            else:
                formatter = ticker.ScalarFormatter()
        else:
            formatter = self.formatter

        self.locator = locator
        self.formatter = formatter
        _log.debug('locator: %r', locator)
        return locator, formatter 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:53,代码来源:colorbar.py

示例9: _ticker

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import IndexLocator [as 别名]
def _ticker(self):
        '''
        Return the sequence of ticks (colorbar data locations),
        ticklabels (strings), and the corresponding offset string.
        '''
        locator = self.locator
        formatter = self.formatter
        if locator is None:
            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()
            else:
                b = self._boundaries[self._inside]
                locator = ticker.FixedLocator(b, nbins=10)
        if isinstance(self.norm, colors.NoNorm):
            intv = self._values[0], self._values[-1]
        else:
            intv = self.vmin, self.vmax
        locator.create_dummy_axis(minpos=intv[0])
        formatter.create_dummy_axis(minpos=intv[0])
        locator.set_view_interval(*intv)
        locator.set_data_interval(*intv)
        formatter.set_view_interval(*intv)
        formatter.set_data_interval(*intv)

        b = np.array(locator())
        ticks = self._locate(b)
        inrange = (ticks > -0.001) & (ticks < 1.001)
        ticks = ticks[inrange]
        b = b[inrange]
        formatter.set_locs(b)
        ticklabels = [formatter(t, i) for i, t in enumerate(b)]
        offset_string = formatter.get_offset()
        return ticks, ticklabels, offset_string 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:45,代码来源:colorbar.py

示例10: _ticker

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import IndexLocator [as 别名]
def _ticker(self):
        '''
        Return the sequence of ticks (colorbar data locations),
        ticklabels (strings), and the corresponding offset string.
        '''
        locator = self.locator
        formatter = self.formatter
        if locator is None:
            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(subs='all')
                elif isinstance(self.norm, colors.SymLogNorm):
                    # The subs setting here should be replaced
                    # by logic in the locator.
                    locator = ticker.SymmetricalLogLocator(
                                      subs=np.arange(1, 10),
                                      linthresh=self.norm.linthresh,
                                      base=10)
                else:
                    if mpl.rcParams['_internal.classic_mode']:
                        locator = ticker.MaxNLocator()
                    else:
                        locator = ticker.AutoLocator()
            else:
                b = self._boundaries[self._inside]
                locator = ticker.FixedLocator(b, nbins=10)
        if isinstance(self.norm, colors.NoNorm) and self.boundaries is None:
            intv = self._values[0], self._values[-1]
        else:
            intv = self.vmin, self.vmax
        locator.create_dummy_axis(minpos=intv[0])
        formatter.create_dummy_axis(minpos=intv[0])
        locator.set_view_interval(*intv)
        locator.set_data_interval(*intv)
        formatter.set_view_interval(*intv)
        formatter.set_data_interval(*intv)

        b = np.array(locator())
        if isinstance(locator, ticker.LogLocator):
            eps = 1e-10
            b = b[(b <= intv[1] * (1 + eps)) & (b >= intv[0] * (1 - eps))]
        else:
            eps = (intv[1] - intv[0]) * 1e-10
            b = b[(b <= intv[1] + eps) & (b >= intv[0] - eps)]
        self._tick_data_values = b
        ticks = self._locate(b)
        formatter.set_locs(b)
        ticklabels = [formatter(t, i) for i, t in enumerate(b)]
        offset_string = formatter.get_offset()
        return ticks, ticklabels, offset_string 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:59,代码来源:colorbar.py


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