python画三条线的折线图

直接上代码

#!usr/bin/env python
# -*- coding:utf-8 -*-
"""
@author: Suyue
@file: zhexiantu.py
@time: 2024/05/10
@desc:
"""
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
matplotlib.rc("font",family='YouYuan')

input_file = 'G:/数浓度/20230618/清水河/shunongdu.xlsx'

df = pd.read_excel(input_file)
x = df['粒径']
y1 = df['作业中']
y2 = df['作业后1h']
y3 = df['作业后2h']
plt.title('数浓度')
plt.xlabel('粒径')
plt.ylabel('数浓度')
plt.plot(x,y1,marker='o',markersize=3)
plt.plot(x,y2,marker='o',markersize=3)
plt.plot(x,y3,marker='o',markersize=3)

# 加断点
# for a ,b in zip(x,y1):
#     plt.text(a, b, b, ha='center', va='bottom', fontsize=10)
# for a ,b in zip(x,y2):
#     plt.text(a, b, b, ha='center', va='bottom', fontsize=10)
# for a ,b in zip(x,y3):
#     plt.text(a, b, b, ha='center', va='bottom', fontsize=10)

plt.legend(['作业中','作业后1h','作业后2h'])

plt.show()

 

posted @ 2024-05-10 19:44  秋刀鱼CCC  Views(66)  Comments(0Edit  收藏  举报