Я привязываюсь к построению квадратичного уравнения с использованием tkinter (фитон)

#python #tkinter

Вопрос:

Я пытаюсь построить график квадратного уравнения, в котором пользователь может ввести 3 ввода (входы a, b и c относятся к: ax^2 bx c ).

может ли кто-нибудь помочь мне найти, где я ошибаюсь?

это код:

 # Import our modules that we are using

from tkinter import *
import matplotlib.pyplot as plt
import numpy as np

# Create the vectors X and Y

a=input("enter the value of a: ")
b=input("enter the value of b: ")
c=input("enter the value of c: ")
r=int(input("enter the range of the graph: "))

x = np.array(range(r))
y=a*x**2 b*x c

root=Tk()
plt.plot(x,y,label='y = x**2')
plt.plot(x,y   c,label='y = x**2   3')
plt.plot(x,y - 5,label='y = x**2 - 5')
plt.plot(x,y - 3,label='y = x**2 - 3')

# Add a title
plt.title('My first Plot with Python')

# Add X and y Label
plt.xlabel('x axis')
plt.ylabel('y axis')

# Add a grid
plt.grid(alpha=.4,linestyle='--')

# Add a Legend
plt.legend()

# Show the plot
plt.show()

root.mainloop()
 

Комментарии:

1. Вы не указали, в чем проблема. Вам не нужно создавать окно tkinter, потому что вы использовали plt.show() .

2. Я думаю , что вам нужно преобразовать входные a данные b и c в целые числа или числа с плавающей запятой.