Python读取excel表格并通过折线图可视化显示 |
您所在的位置:网站首页 › 成绩折线统计图怎么做表格 › Python读取excel表格并通过折线图可视化显示 |
Python读取excel表格并通过折线图可视化显示 本文是通过pandas和matplotlib模块实现可视化的。如有不足请指正。 excel表格为 第一步 导入模块: import pandas as pd import matplotlib.pyplot as plt第二步 使用pandas读取excel文件: df = pd.read_excel("C:\\Users\\ASUS\\Desktop\\test.xlsx")然后我们print读取的数据看一下 print(df)结果如下: 导出money1这一列的数据: print(df["money1"])第三步: plt显示: 横坐标为df[“time”],纵坐标1为df[“money1”],纵坐标2为df[“money2”],markerfacecolor='blue’为填充的颜色 plt.plot(df["time"],df["money1"],label='money1',linewidth=3,color='r',marker='o', markerfacecolor='blue',markersize=12) plt.plot(df["time"],df["money2"],label='money2',linewidth=3,color='y',marker='o', markerfacecolor='blue',markersize=12)标题显示 plt.xlabel("time") plt.ylabel('money') plt.title("summy of input") plt.legend() plt.grid() plt.show()折线图如下: 完整代码: import pandas as pd import matplotlib.pyplot as plt df = pd.read_excel("C:\\Users\\ASUS\\Desktop\\test.xlsx") print(df) print(df["money1"]) plt.plot(df["time"],df["money1"],label='money1',linewidth=3,color='r',marker='o', markerfacecolor='blue',markersize=12) plt.plot(df["time"],df["money2"],label='money2',linewidth=3,color='y',marker='o', markerfacecolor='blue',markersize=12) plt.xlabel("time") plt.ylabel('money') plt.title("summy of input") plt.legend() plt.grid() plt.show() |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |