python使用matplotlib画论文的图

import matplotlib.pyplot as plt
import matplotlib

matplotlib.use('TkAgg')

y1 = [42.42, 43.03, 44.20, 45.87, 47.89]
y2 = [52.25, 53.94, 54.75, 55.88, 58.18]
y3 = [62.79, 63.09, 64.30, 66.03, 67.37]
y4 = [72.79, 73.09, 74.30, 76.03, 77.37]
y5 = [82.79, 83.09, 84.30, 86.03, 87.37]

fig, ax = plt.subplots(figsize=(6.4, 4.8), dpi=100)

x = ["Base", "+a", "+b", "+c", "+d"]

ax.plot(x, y1, label='sample1', linestyle='-', marker='*', markersize='10')
ax.plot(x, y2, label='sample2', linestyle='-', marker='p', markersize='10')
ax.plot(x, y3, label='sample3', linestyle='-', marker='o', markersize='10')
ax.plot(x, y4, label='sample4', linestyle=':', marker='x', markersize='10')
ax.plot(x, y5, label='sample5', linestyle=':', marker='x', markersize='10')

ax.set_xlabel('x axis', fontsize=13)
ax.set_ylabel('y axis', fontsize=13)

ax.tick_params(axis='both', labelsize=11)

ax.yaxis.grid(True, linestyle='-.')

legend = ax.legend(loc='best')
plt.show()
# 保存为png
fig.savefig('./pic.png')
# 保存为pdf
fig.savefig('./pic.pdf', format='pdf')

生成的图如下所示:
在这里插入图片描述

  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值