[自用代码]画直线图和折线图的代码

import matplotlib.pyplot as plt
import matplotlib
from matplotlib.ticker import MultipleLocator
import numpy as np

y = [52.96,  52.84,  50.62,  55.35,  55.78,  56.03,  57.44,  58.75,  60.82]
y2 =[52.90,  52.90,  52.90,  52.90,  52.90,  52.90,  52.90,  52.90,  52.90]
y3 =[58.90,  58.90,  58.90,  58.90,  58.90,  58.90,  58.90,  58.90,  58.90]
x = ["10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%"]



plt.rcParams["font.family"] = "Times New Roman"

fig, axes = plt.subplots(1, 1, figsize=(8, 4))
# 折线图
l1 = plt.plot(x, y, linestyle='-', color='black', marker='x', linewidth=1.5, label = "SAR-ISAR")
l2 = plt.plot(x, y3, linestyle='-.', color='red', marker='', linewidth=1.5, label = "SAR")
l3 = plt.plot(x, y2, linestyle=':', color='blue', marker='', linewidth=1.5, label = "ISAR")
plt.legend()
# plt.hlines(0, 0, 0.5, colors = "r", linestyles = "dashed")
# 设置最小刻度间隔
# axes.yaxis.set_minor_locator(MultipleLocator(2.5))
# axes.xaxis.set_minor_locator(MultipleLocator(0.5))
# 画网格线
# axes.grid(which='minor', c='lightgrey')
# 设置x、y轴标签
axes.set_ylabel("Accuracy")
axes.set_xlabel("SAR Ratio of SAR-ISAR Data")
# 设置y轴的刻度
# axes.set_yticks([51,52,53,54,55,56,57,58,59,60,61])
# 对每个数据点加标注
for x_, y_ in zip(x, y):
    axes.text(x_, y_, y_, ha='left', va='bottom')

axes.text(x[8], y2[8], y2[8], ha='left', va='bottom')
axes.text(x[8], y3[8], y3[8], ha='left', va='bottom')

# 展示图片
plt.show()
fig.savefig("plot.pdf", dpi=800)

在这里插入图片描述

参考链接

Plot-Pictures-Tutorial-for-Paper

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

deyiwang89

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值