Here is my code: to plot some bar graph of some data set.
import matplotlib.pyplot as plt
import numpy as np
#Declaring data
year = []
relative_recurrence = []
#Open data file
f = open('relative recurrence plot.txt','r')
for row in f:
row = row.split(' ')
year.append(int(row[0]))
relative_recurrence.append(float(row[1]))
#Plot the graph
plt.bar(year, relative_recurrence,color = 'grey', label = 'HILDCAAS', edgecolor='black')
plt.xticks(np.arange(min(year), max(year) + 1, 5))
# Label for x-axis
plt.xlabel("YEAR")
# Label for y-axis
plt.ylabel("Relative Occurence")
plt.show()
plt.savefig('recurrence plot.png')
I used the savefig() command to save my plot. But it didn't work. Getting no error, but the image saved is blank. Please tell the mistake. Thankyou in advance.