I have a CSV file (Data.csv):
2012-01-01,0
2012-01-02,1
2012-01-03,8
2012-01-04,1
...etc
I am trying to make a bar graph, the dates on the x axis and the values on the y axis:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
def graph():
date, value = np.loadtxt('Data.csv', delimiter=',', unpack=True,
converters = {0: mdates.strpdate2num('%Y-%m-%d')})
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1, axisbg='white')
plt.plot_date(x=date, y=value, fmt='-')
plt.title('Title')
plt.ylabel('Value')
plt.xlabel('Date')
plt.show()
graph()
Unfortunately, this is a line graph.
Could someone please assist?