python给折线图添加标记

我需要记录飞机作业的开始时间和结束时间

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
 
@author:JK
@file:jisuan.py
@time:2024/03/$
{DAY}
@desc:
"""
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
 
input_file = 'D:/呼和浩特土左旗_second.xlsx'
 
df = pd.read_excel(input_file)
x_axis_data = df['时间']
y_axis_data = df['NT']
start_time = df.at[11,'时间'] #时间那列对应的飞机作业开始时间的行数,为第11行
start_NT = df.at[11,'NT']    # nt值那列对应的飞机作业开始时间的行数,为第11行
end_time = df.at[118,'时间']
end_NT = df.at[118,'NT']
 
plt.plot(x_axis_data, y_axis_data, ls="-", alpha=0.5, linewidth=1, label='abc')
plt.legend
plt.gca().xaxis.set_major_locator(ticker.MultipleLocator(30))
plt.scatter(start_time,start_NT,color='red',s=50)
plt.scatter(end_time,end_NT,color='red',s=50)
plt.xlabel('tuzuoqi')
plt.ylabel('NT')
 
plt.show()

 结果如图:

 

posted @   秋刀鱼CCC  Views(128)  Comments(0Edit  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· Vue3状态管理终极指南:Pinia保姆级教程
点击右上角即可分享
微信分享提示