root=Tk() #创建窗体 root.title("22080007韩罗合美绘图和爬虫") #给窗体命名 root.geometry("300x300") #设置窗体尺寸 def sta(): #定义一个函数 df = pd.read_excel('实验数据2.xls') plt.plot(df['x'],df['y']) plt.show()bt=Button(root,text="读取并绘图",width=20,font=("宋体",20),command=sta) bt.place(x=60,y=100) root.mainloop()
时间: 2024-03-31 07:38:50 浏览: 18
这段代码是用 Python 的 Tkinter 模块创建了一个名为 "22080007韩罗合美绘图和爬虫" 的窗口,窗口大小为 300x300 像素,并在窗口中添加了一个名为 "读取并绘图" 的按钮。当用户点击该按钮时,将会调用名为 "sta" 的函数,该函数会读取名为 "实验数据2.xls" 的 Excel 文件中的数据,并绘制出图形展示出来。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![.rar](https://img-home.csdnimg.cn/images/20210720083646.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![xlsx](https://img-home.csdnimg.cn/images/20210720083732.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)