'Trying to create y=mx+c graph with Matplotlib on python but the graph doesn't show up after user input
When I run my code the matplotlib window crashes after user input, Here is the python code below:
import matplotlib.pyplot as plt
import random
class DataGenerator:
def value(x_min, x_max) -> int:
return random.randint(x_min,x_max)
def generator(x_min,x_max) -> int:
data = [dataGenerator.value(x_min,x_max) for _ in range(20)]
m = (x_max - x_min)
c = x_min
y = []
for x in data:
values = ((m*x) + c)
y.append(values)
plt.plot(y,data)
plt.show
x_min = int(input("Enter the minimum value "))
x_max = int(input("Enter the maximum value "))
dataGenerator = DataGenerator
dataGenerator.generator(x_min, x_max)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
