matplotlib画图

创建新的画布

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()

  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值