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


Python ticker.LogFormatterExponent方法代码示例

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


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

示例1: test_LogFormatterExponent

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import LogFormatterExponent [as 别名]
def test_LogFormatterExponent():
    class FakeAxis(object):
        """Allow Formatter to be called without having a "full" plot set up."""
        def get_view_interval(self):
            return 1, 10

    i = np.arange(-3, 4, dtype=float)
    expected_result = ['-3', '-2', '-1', '0', '1', '2', '3']
    for base in [2, 5, 10, np.pi, np.e]:
        formatter = mticker.LogFormatterExponent(base=base)
        formatter.axis = FakeAxis()
        vals = base**i
        labels = [formatter(x, pos) for (x, pos) in zip(vals, i)]
        nose.tools.assert_equal(labels, expected_result)

    # Should be a blank string for non-integer powers if labelOnlyBase=True
    formatter = mticker.LogFormatterExponent(base=10, labelOnlyBase=True)
    formatter.axis = FakeAxis()
    nose.tools.assert_equal(formatter(10**0.1), '')

    # Otherwise, non-integer powers should be nicely formatted
    locs = np.array([0.1, 0.00001, np.pi, 0.2, -0.2, -0.00001])
    i = range(len(locs))
    expected_result = ['0.1', '1e-05', '3.14', '0.2', '-0.2', '-1e-05']
    for base in [2, 5, 10, np.pi, np.e]:
        formatter = mticker.LogFormatterExponent(base, labelOnlyBase=False)
        formatter.axis = FakeAxis()
        vals = base**locs
        labels = [formatter(x, pos) for (x, pos) in zip(vals, i)]
        nose.tools.assert_equal(labels, expected_result) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:32,代码来源:test_ticker.py

示例2: test_basic

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import LogFormatterExponent [as 别名]
def test_basic(self, labelOnlyBase, base, exponent, locs, positions,
                   expected):
        formatter = mticker.LogFormatterExponent(base=base,
                                                 labelOnlyBase=labelOnlyBase)
        formatter.axis = FakeAxis(1, base**exponent)
        vals = base**locs
        labels = [formatter(x, pos) for (x, pos) in zip(vals, positions)]
        assert labels == expected 
开发者ID:holzschu,项目名称:python3_ios,代码行数:10,代码来源:test_ticker.py

示例3: test_blank

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import LogFormatterExponent [as 别名]
def test_blank(self):
        # Should be a blank string for non-integer powers if labelOnlyBase=True
        formatter = mticker.LogFormatterExponent(base=10, labelOnlyBase=True)
        formatter.axis = FakeAxis()
        assert formatter(10**0.1) == '' 
开发者ID:holzschu,项目名称:python3_ios,代码行数:7,代码来源:test_ticker.py


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