Advertisement
crabbypup

graph.py

Oct 5th, 2015
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. #!/usr/bin/python
  2. import matplotlib as mpl
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5. import matplotlib.dates as mdates
  6. import datetime as dt
  7.  
  8. dates = [] #create empty data set
  9.  
  10. with open('/media/Library/size_history.csv','r') as f:
  11.     for line in f:
  12.         dates.append(line.split(',')[0])       
  13.  
  14. x = [dt.datetime.strptime(d,'%Y/%m/%d').date() for d in dates]
  15. y = np.genfromtxt('/media/Library/size_history.csv', delimiter=',', usecols=(1))
  16.  
  17. plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
  18. plt.gca().xaxis.set_major_locator(mdates.WeekdayLocator(byweekday=6,interval=1,tz=None))
  19. plt.gca().set_ylim(top=10870) #size of NAS in GB
  20. plt.gca().set_ylim(bottom=8000) #lowest capacity on record
  21. plt.plot(x,y)
  22. plt.title('Storage Use Trend')
  23. plt.ylabel('Storage Used(GB)')
  24. plt.xlabel('Date')
  25. plt.gcf().autofmt_xdate()
  26. plt.grid(True,color='k')
  27.  
  28. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement