當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。