Advertisement
mdan

TS_graph_1

Feb 11th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Mon Feb 12 01:44:16 2018
  5.  
  6. @author: dan
  7. """
  8. # Importam cele de trebuinta
  9.  
  10. import xlrd
  11. import matplotlib.pyplot as plt
  12. from matplotlib.backends.backend_pdf import PdfPages
  13.  
  14. # Citim coloanele cu Luna / Anul, Mediafax si Agerpres
  15.  
  16. tabel = xlrd.open_workbook('TSdataset2.xlsx')
  17. first_sheet = tabel.sheet_by_index(0)
  18.  
  19. x = [first_sheet.cell_value(i, 0) for i in range(first_sheet.nrows)]
  20. y = [first_sheet.cell_value(i, 1) for i in range(first_sheet.nrows)]
  21. z = [first_sheet.cell_value(i, 2) for i in range(first_sheet.nrows)]
  22.  
  23. # Încercăm un plot, să vedem cu ochii noștri
  24.  
  25. plt.figure(2)
  26.  
  27. plt.subplot(211)
  28. plt.ylabel('Mediafax')
  29. plt.xlabel('2018 - 2012')
  30. plt.plot(y)
  31.  
  32. plt.subplot(212)
  33. plt.ylabel('Agerpres')
  34. plt.xlabel('2018 - 2012')
  35. plt.plot(z)
  36.  
  37.  
  38.  
  39. # Salvăm rezultatele intr-un pdf ca să avem dovada needitabilă :))))
  40.  
  41. with PdfPages('Grafice.pdf') as pdf:
  42.     plt.figure(figsize=(10, 5))
  43.     plt.plot(y)
  44.     plt.title('Mediafax')
  45.     pdf.savefig()
  46.     plt.close()
  47.    
  48.     plt.figure(figsize=(10, 5))
  49.     plt.plot(z)
  50.     plt.title('Agerpres')
  51.     pdf.savefig()
  52.     plt.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement