max_min_data[4][0] ] m_min = [ max_min_data[1][1], max_min_data[2][1], max_min_data[3][1], max_min_data[4][1] ] r_max = [ max_min_data[1][2], max_min_data[2][2], max_min_data[3][2], max_min_data[4][2] ] r_min = [ max_min_data[1][3], max_min_data[2][3], max_min_data[3][3], max_min_data[4][3] ] Plot.create_figure((2.0, 2.0)) Plot.plot_setting(111, xtick_direction='in') bar_width = 0.3 bar_gap = 0.05 bar1 = Plot.plot_bar([1, 2, 3, 4], mem_data, color=Color.color[0], bar_width=bar_width) bar2 = Plot.plot_bar([ 1 + bar_gap + bar_width, 2 + bar_gap + bar_width, 3 + bar_gap + bar_width, 4 + bar_gap + bar_width ], req_data, color=Color.color[1], bar_width=bar_width) line1 = Plot.plot_hlines(m_max, [
from exp.tools.utils import Utils import numpy as np from exp.tools.plot import Plot from exp.tools.plot import Save # 这是一个箱型图例子 name = ['art', 'sail', 'poptrie'] art_data = Utils.read_csv('art' + '_loc512_rand.csv', only_data=True)[1:] header, sail_data = Utils.read_csv('sail' + '_loc512_rand.csv') sail_data = sail_data[1:] poptrie_data = Utils.read_csv('poptrie' + '_loc512_rand.csv', only_data=True)[1:] Plot.create_figure((5, 2.5)) Plot.plot_setting(131) f = Plot.plot_box(art_data) Plot.plot_xlim(0, 10.5) Plot.plot_xticks(np.arange(1, 11, 1), ['1', '', '', '8', '', '', '64', '', '', '512'], font_size=14) Plot.plot_ylim(0, 820) Plot.plot_yticks(np.arange(0, 1000, 200), font_size=14) Plot.plot_xlable('locality', font_size=20) Plot.plot_ylabel('speed(Mpps)', font_size=20) Plot.plot_grid() Plot.plot_text(1, 700, name[0].capitalize()) Plot.plot_setting(132, ytick_dircetion='in') f = Plot.plot_box(sail_data)
# 这是一个多个柱子并行的柱状图 # 读取的数据文件为:tx-rx.csv # 读取数据 header, data = Utils.read_csv('tx-rx.csv') name = header[1:] xtick_label = data[0] base_data = data[1] art_data = data[2] sail_data = data[3] poptrie_data = data[4] # 开始绘图 Plot.create_figure((3, 2.5)) Plot.plot_setting(111) bar_width = 0.2 bar1 = Plot.plot_bar([1, 2, 3, 4, 5], base_data, bar_width=bar_width, color=Color.color[0]) bar2 = Plot.plot_bar([ 1 + bar_width, 2 + bar_width, 3 + bar_width, 4 + bar_width, 5 + bar_width ], art_data, bar_width=bar_width, color=Color.color[1]) bar3 = Plot.plot_bar([ 1 + bar_width * 2, 2 + bar_width * 2, 3 + bar_width * 2, 4 + bar_width * 2, 5 + bar_width * 2
import numpy as np from exp.tools.utils import Utils from exp.tools.plot import Plot from exp.tools.plot import Save # 这是一幅包含了3个箱型图的绘图例子 # 读取的文件是:llc_25_box.csv llc_50_box.csv llc_75_box.csv # 三个csv文件 # 读取文件 header, data_25 = Utils.read_csv('llc_25_box_res.csv') data_50 = Utils.read_csv('llc_50_box_res.csv', only_data=True) data_75 = Utils.read_csv('llc_75_box_res.csv', only_data=True) Plot.create_figure((4.5, 2.5)) Plot.plot_setting(131) Plot.plot_box(data_25) Plot.plot_xticks(np.arange(1, 4, 1), ['Art', 'Sail', 'Poptrie'], font_size=16, rotation=20) Plot.plot_yticks(np.arange(100, 350, 50), font_size=16) Plot.plot_ylabel('lookup speed(Mpps)', font_size=20) Plot.plot_ylim(100, 320) Plot.plot_grid() Plot.plot_text(0.4, 330, 'LLC=25%', fontsize=17) Plot.plot_setting(132, ytick_dircetion='in') Plot.plot_box(data_50) Plot.plot_xticks(np.arange(1, 4, 1), ['Art', 'Sail', 'Poptrie'], font_size=16, rotation=20) Plot.plot_yticks(np.arange(100, 350, 50), ['', '', '', '', ''], font_size=16) Plot.plot_ylim(100, 320) Plot.plot_grid()
wo_poptrie = wo_data[3] w_art = w_data[1] w_sail = w_data[2] w_poptrie = w_data[3] wo_l1_data = [wo_art[0], wo_sail[0], wo_poptrie[0]] # wo 数据 wo_l2_data = [wo_art[1], wo_sail[1], wo_poptrie[1]] wo_l3_data = [wo_art[2], wo_sail[2], wo_poptrie[2]] w_l1_data = [w_art[0], w_sail[0], w_poptrie[0]] # w 数据 w_l2_data = [w_art[1], w_sail[1], w_poptrie[1]] w_l3_data = [w_art[2], w_sail[2], w_poptrie[2]] # 开始绘图 color = ['#e6550d', '#fdae6b', '#fee6ce'] Plot.create_figure((5, 3)) Plot.plot_setting(121) bar1 = Plot.plot_bar(np.arange(1, 4, 1), wo_l1_data, color=color[0], bar_width=0.3) bar2 = Plot.plot_bar(np.arange(1, 4, 1), wo_l2_data, color=color[1], bottom=wo_l1_data, bar_width=0.3) bar3 = Plot.plot_bar( np.arange(1, 4, 1), wo_l3_data, color=color[2], bar_width=0.3,
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Author: zzh # @Date: 2020/1/9 19:46 from exp.tools.plot import Plot from exp.tools.plot import Save from exp.tools.plot import Color from exp.tools.utils import Utils import numpy as np header, data = Utils.read_csv('example7.csv') Plot.create_figure((2.0, 2.1)) Plot.plot_setting(111) bar_width = 0.4 Plot.plot_bar(1, data[0], color=Color.color[0], bar_width=bar_width) Plot.plot_bar(2, data[1], color=Color.color[1], bar_width=bar_width) Plot.plot_bar(3, data[2], color=Color.color[2], bar_width=bar_width, hatch='o') Plot.plot_bar(4, data[3], color=Color.color[3], bar_width=bar_width, hatch='\\') Plot.plot_grid() Plot.plot_yticks(np.arange(0, 80, 20), font_size=14) Plot.plot_xticks([1, 2, 3, 4], ['Art', 'Sail', 'Poptrie', 'DXR'], font_size=14, rotation=40) line1, = Plot.plot([0.8, 1.2], [34, 34], 'Art active', linestyle='-') Plot.plot_ylabel('memory(MB)', font_size=18) Plot.plot_legend([line1], ['Art-active'], 1, bbox_to_anchor=(1.1, 1.08), loc='upper right', font_size=14) Save.save('example7')
from exp.tools.plot import Save from exp.tools.plot import Plot # 这是一个并行的柱形图例子 # 读取的文件为:cache-1-0.csv # 读取文件 header, data = Utils.read_csv('cache-1-0.csv') art_data = data[1] sail_data = data[2] poptrie_data = data[3] wo_data = [art_data[0], sail_data[0], poptrie_data[0]] w_data = [art_data[1], sail_data[1], poptrie_data[1]] # 绘图 Plot.create_figure((3.2, 2)) Plot.plot_setting(111) bar_width = 0.2 bar1 = Plot.plot_bar([1, 2], art_data, color='#e6550d') bar2 = Plot.plot_bar([1 + bar_width, 2 + bar_width], sail_data, color='#fdae6b', hatch='/') bar3 = Plot.plot_bar([1 + bar_width * 2, 2 + bar_width * 2], poptrie_data, color='#fee6ce', hatch='\\') Plot.plot_xticks([1 + bar_width, 2 + bar_width], ['w/o comp', 'w comp']) Plot.plot_show_barAboveText(bar1) Plot.plot_show_barAboveText(bar2)
from exp.tools.plot import Plot from exp.tools.plot import Save import numpy as np # 这是一个折线图 # 读取csv文件中的内容 header, data = Utils.read_csv('all_loc512_normal.csv') # 从读取的csv文件中分别获取不同类别的数据 locality = data[0] art = data[1] sail = data[2] poptrie = data[3] Plot.create_figure((3, 2.5)) Plot.plot_setting(111) line1, = Plot.plot(np.arange(0,10,1),art, label=str(header[1]).capitalize(),color='#e6550d') line2, = Plot.plot(np.arange(0,10,1),sail, label=str(header[2]).capitalize(), linestyle='--',color='#fdae6b') line3, = Plot.plot(np.arange(0,10,1),poptrie, label=str(header[3]).capitalize(), color='#fee6ce', marker='o') Plot.plot_xlable('locality', font_size=20) Plot.plot_ylabel('speed(Mpps)', font_size=20) Plot.plot_xticks(np.arange(0, 10, 3), ['1', '8', '64', '512']) Plot.plot_yticks(np.arange(200, 1000, 200)) Plot.plot_ylim(200, 820) Plot.plot_grid() Plot.plot_legend([line1, line2, line3], ['Art', 'Sail', 'Poptrie'], ncol=2,bbox_to_anchor=(0,1.05),loc='upper left',font_size=16) # plt.figure(num=1, figsize=(3, 2.5), dpi=600) # ax = plt.subplot(111) # ax.set_axisbelow(True) # 设置网格线和坐标轴是在figure的上面还是在下面