问题描述:用python读取excel表格,将第一列的值作为横坐标,第二列的值作为纵坐标的值,并画出横纵坐标
代码:
import pandas as pd
import matplotlib.pyplot as plt
# 读取Excel文件
df = pd.read_excel('example.xlsx')
# 获取第一列和第二列的数据
x = df.iloc[:, 0]
y = df.iloc[:, 1]
# 绘制散点图
plt.scatter(x, y)
# 添加横纵坐标标签
plt.xlabel('X Label')
plt.ylabel('Y Label')
# 显示图形
plt.show()