创建新的画布
plt.figure(idx)
CDF图
X轴不具备物理意义
func_data = pd.read_csv(_file_name(day,"execution")[0]).sort_values(by=['Count'], ascending=False)
total_counts = np.sum(func_data['Count'])
samples = len(func_data)
plt.rcParams["figure.figsize"] = (4, 3)
fig, ax = plt.subplots(1, 1)
ax.set_ylim(0)
tmp = np.cumsum(func_data['Count'].values/total_counts)
ax.plot(range(samples),tmp,linestyle="-.",
linewidth=line_width,color=color_dark_gray)
ax.set_xlabel("Function ID",fontsize=self.label_size)
ax.set_ylabel("Invocation CDF",fontsize=self.label_size)
ax.text(1.2, 0.1, "Popular"+'\n'+" func.", fontsize=14, color=color_red, weight='bold')
yticks_ = [0, 0.2, 0.4, 0.6, 0.8, 1]
ax.set_yticks(yticks_, yticks_)
ax.set_xscale('log')
ax.tick_params(axis='y', labelsize=self.tick_font_size)
ax.tick_params(axis='x', labelsize=self.tick_font_size-3.5)
ax.grid(visible=True,linestyle='--', linewidth=1)
plt.tight_layout()
plt.savefig("./stats/function_execution/day_"+str(day)+"/"+"invocation_cdf.pdf")
plt.show()
X轴具备物理意义
n, bins, patches = plt.hist(1 - func_data.nlargest(columns=['Count'], n=numbers)['ratio'], 1000000, density=True, histtype='step', range=(lower, upper),
cumulative=True, label='Top(' + str(samples) + ')')
Bar图
plt.rcParams["figure.figsize"] = [8, 2.5]
fig, ax1 = plt.subplots()
# matplotlib.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
# 构建数据
x = ['inception_v3', 'resnet_101', 'vgg11', 'mobilenet_v3']
avg,std = ...,....,
bar_width = 0.4
color_list = {"realign":color_grey,"grouping":color_dark_grey}
ax1.axhline(1,0,len(x)-1,ls="--",color=color_red,linewidth=2)
ax1.bar(x=np.arange(len(x)), height=avg,yerr=np.array(std)/2,error_kw = err_bar_kw, color=color_grey, alpha=1,
width=bar_width)
ax1.set_axisbelow(True)
ax1.grid(axis='y',ls="dotted",linewidth=1,zorder=0)
ax1.set_xticks(np.arange(len(x)))
ax1.set_xticklabels(('Inc', 'Res', 'VGG', 'Mob'))
ax1.yaxis.set_major_locator(MultipleLocator(0.2))
ax1.set_ylabel("GPU share \n (Normalized)", label_font)
ax1.tick_params(axis='y', labelsize=tick_font["size"])
ax1.tick_params(axis='x', labelsize=tick_font["size"])
#ax1.legend(prop=legend_font,loc="upper center",bbox_to_anchor=(-0.01,1.25,1,0),ncol=3,columnspacing=0.2,handletextpad=0.2,framealpha=0)#handlelength=1,
#fig.tight_layout()
plt.savefig("./image/asplos23/exp_grouping_overall.pdf", bbox_inches='tight', pad_inches=0)
fig.show()