python 读取excel文件并画折线图

import pandas as pd
from pylab import *
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt

# Load the Excel file
#此处“\”需要转义
file_path = '文件目录\\dddd.xlsx'

# Read the Excel file
df = pd.read_excel(file_path)

# Extract the required columns for plotting
\\df['列标题']
original_x = df['x原始坐标']
predicted_x = df['x预测坐标']



# True value
true_value_x=730
true_value_y =920
true_value_d =1140
true_value_a = 14

# Create a line plot
plt.figure(figsize=(10, 6))

mpl.rcParams['font.sans-serif'] = ['SimHei']
plt.plot(original_x, label='x', marker='o')
plt.plot(predicted_x, label='x预测', marker='x')
plt.axhline(y=true_value_x, color='r', linestyle='-', label='真实值')

# Add labels and title
plt.xlabel('Index')
plt.ylabel('Coordinates')
plt.title('x坐标 vs 预测坐标')
plt.legend()
//保存图片
plt.savefig('./x原始vs预测.jpg')
# Display the plot
plt.show()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值