# -*- coding: utf-8 -*- """ Created on Tue Oct 18 20:46:18 2022 @author: Roman """ import tkinter as tk import numpy as np import matplotlib.pyplot as plt import json def plot(): data = { "x": [], "y": [] } with open('data.json', 'r') as f: data = json.load(f) plt.figure() plt.plot(data['x'], data['y'], "*r", label='Данные') x = np.linspace(min(data['x']), max(data['x']), 1000) for i in range(1, 6): p = np.polyfit(data['x'], data['y'], i) y = np.polyval(p, x) plt.plot(x, y, label=f"Полином {i}-й степени") plt.legend() plt.grid() plt.savefig('last_image.png') img = tk.PhotoImage(file='last_image.png') image_label.configure(image=img) image_label.image = img window = tk.Tk() img = tk.PhotoImage(file='last_image.png') image_label = tk.Label(text="Здесь буде график") image_label.grid(row=0, column=0) button = tk.Button(text='Построить график', command=plot) button.grid(row=1, column=0) window.mainloop()