Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- Created on Mon Feb 12 01:44:16 2018
- @author: dan
- """
- # Importam cele de trebuinta
- import xlrd
- import matplotlib.pyplot as plt
- from matplotlib.backends.backend_pdf import PdfPages
- # Citim coloanele cu Luna / Anul, Mediafax si Agerpres
- tabel = xlrd.open_workbook('TSdataset2.xlsx')
- first_sheet = tabel.sheet_by_index(0)
- x = [first_sheet.cell_value(i, 0) for i in range(first_sheet.nrows)]
- y = [first_sheet.cell_value(i, 1) for i in range(first_sheet.nrows)]
- z = [first_sheet.cell_value(i, 2) for i in range(first_sheet.nrows)]
- # Încercăm un plot, să vedem cu ochii noștri
- plt.figure(2)
- plt.subplot(211)
- plt.ylabel('Mediafax')
- plt.xlabel('2018 - 2012')
- plt.plot(y)
- plt.subplot(212)
- plt.ylabel('Agerpres')
- plt.xlabel('2018 - 2012')
- plt.plot(z)
- # Salvăm rezultatele intr-un pdf ca să avem dovada needitabilă :))))
- with PdfPages('Grafice.pdf') as pdf:
- plt.figure(figsize=(10, 5))
- plt.plot(y)
- plt.title('Mediafax')
- pdf.savefig()
- plt.close()
- plt.figure(figsize=(10, 5))
- plt.plot(z)
- plt.title('Agerpres')
- pdf.savefig()
- plt.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement