matplotlib按照论文要求绘图并保存pdf格式

学术论文的图绘制要求:

  • 尽量清楚, 字体、曲线、标记尽量大
  • 分辨率要求,最低dpi要求,例如dpi最低300
  • 保存格式,例如pdf
  • 无颜色印刷,需要标记来区分类别

一个绘图示例

    font_size = 13 #字体大小
    label_size = 11.5 #label
    lw = 2 #线宽
    font = fm.FontProperties(size=font_size)
    
    for results in complet_results:
        if results['mode'] == 'method1':
            label = 'method1'
            marker = 'o'
        elif results['mode'] == 'method2':
            label = 'method2'
            marker = '+'
        elif results['mode'] == 'method3':
            label = 'method3'
            marker = '*'

        plt.plot(results['test_acc_global'], label=label,  marker=marker, linewidth=lw)

    # plt.title(data_name, fontsize=font_size)
    plt.xlabel('Rounds', fontproperties=font)
    plt.ylabel('Test Acc', fontproperties=font)
    plt.grid() #可选
    plt.xlim(0, 100) #x轴显示范围
    plt.ylim(0.75, 0.91) #y轴显示范围
    plt.legend(shadow=False, fontsize=font_size, loc=4) #图例
    plt.tick_params(labelsize=label_size) #刻度大小
    save_path = os.path.join(save_dir, '{}_test_acc_detail'.format(data_name.replace(',', '_')))
    plt.savefig(save_path+'.jpg' , dpi=300, bbox_inches='tight') #dpi
    plt.savefig(save_path+'.pdf', bbox_inches='tight') #pdf
    plt.show()
    plt.close()
  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值