The pyplot does not save the figure

I have the code that uses pyplot function but the plot that is saved shows an empty area.
Removing variables did not give result. What is wrong??

import numpy as np
import matplotlib.pyplot as plt
print('Квадратическая функция y=ax^2+bx+c.')
a = 1 
b = 1 
c = 1 
x = np.linspace(-100, 100, 1000)
y = a*x**2 + b*x + c  
fig, ax = plt.subplots()
ax.plot(x, y)
print('the graph was saved')

>Solution : should come after plt.savefig()

Explanation: clears the whole thing, so anything afterwards will happen on a new empty figure

so try:


Leave a Reply