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


Python ticker.EngFormatter方法代码示例

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


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

示例1: plot_specgrams

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import EngFormatter [as 别名]
def plot_specgrams(base_dir=CHART_DIR):
    """
    Plot a bunch of spectrograms of wav files in different genres
    """
    plt.clf()
    genres = ["classical", "jazz", "country", "pop", "rock", "metal"]
    num_files = 3
    f, axes = plt.subplots(len(genres), num_files)

    for genre_idx, genre in enumerate(genres):
        for idx, fn in enumerate(glob.glob(os.path.join(GENRE_DIR, genre, "*.wav"))):
            if idx == num_files:
                break
            axis = axes[genre_idx, idx]
            axis.yaxis.set_major_formatter(EngFormatter())
            axis.set_title("%s song %i" % (genre, idx + 1))
            plot_specgram(axis, fn)

    specgram_file = os.path.join(base_dir, "Spectrogram_Genres.png")
    plt.savefig(specgram_file, bbox_inches="tight")

    plt.show() 
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:24,代码来源:fft.py

示例2: main

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import EngFormatter [as 别名]
def main():
    mm = machinemodel.MachineModel(sys.argv[1])
    kernels = sorted(mm['benchmarks']['kernels'])
    cache_levels = sorted(mm['benchmarks']['measurements'])
    fig, axs = plt.subplots(len(cache_levels), 1, figsize=(7, 14), tight_layout=True)
    lines = {}
    for i, cache_level in enumerate(cache_levels):
        max_bw = 0
        max_bw_core = 0

        axs[i].set_title(cache_level)
        formatter1 = EngFormatter(places=0)  # , sep="\N{THIN SPACE}")  # U+2009
        axs[i].yaxis.set_major_formatter(formatter1)
        if cache_level == 'L1':
            axs[i].set_ylabel("Bandwidth [B/s]")
        else:
            axs[i].set_ylabel("Bandwidth [B/s]\n(incl. write-allocate)")
        axs[i].set_xlabel('cores')
        # axs[i].set_xscale('log')

        for ki, kernel in enumerate(kernels):
            if cache_level == 'L1':
                # L1 does not have write-allocate, so everything is measured correctly
                factor = 1.0
            else:
                measurement_kernel_info = mm['benchmarks']['kernels'][kernel]
                factor = (float(measurement_kernel_info['read streams']['bytes']) +
                          2.0 * float(measurement_kernel_info['write streams']['bytes']) -
                          float(measurement_kernel_info['read+write streams']['bytes'])) / \
                         (float(measurement_kernel_info['read streams']['bytes']) +
                          float(measurement_kernel_info['write streams']['bytes']))

            for SMT in mm['benchmarks']['measurements'][cache_level]:
                measurements = [
                    bw*factor
                    for bw in mm['benchmarks']['measurements'][cache_level][SMT]['results'][kernel]]
                max_bw = max(measurements+[max_bw])
                max_bw_core = max(max_bw_core, measurements[0])
                lines[kernel], = axs[i].plot(
                    range(1, 1 + len(measurements)),
                    measurements,
                    linestyle=['-', '--', '..', '-.'][SMT-1],
                    color=kernel_colors[ki])
        axs[i].set_xlim(1)
        axs[i].axhline(max_bw, color='black')
        axs[i].axhline(max_bw_core, color='black')
        axs[i].set_yticks(np.append(axs[i].get_yticks(), [float(max_bw), float(max_bw_core)]))
        axs[i].set_xticks(range(1, 1+len(measurements)))
    fig.legend(lines.values(), lines.keys(), 'lower center', ncol=10)
    fig.savefig(sys.argv[1]+'.pdf')
    #plt.show() 
开发者ID:RRZE-HPC,项目名称:kerncraft,代码行数:53,代码来源:plot_machine_file.py


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