I’m trying to plot figures and save it as a file and show it in HTML. I’m using flask and putting all the code for histogram generation in a function. But each time the histogram is plotted based on different input of the users, each histogram are getting overlapped on each other.
I’m expecting it to overwrite the image already saved as the figure and create a new figure with the histogram in it. Here’s my code…
plt.hist(course_student_marks)
plt.xlabel('Marks')
plt.ylabel('Frequency')
plt.savefig('static/assets/histogram_image.png')