# -*- coding: utf-8 -*-
"""
Created on Thu May 11 15:07:38 2017
http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.plot
http://matplotlib.org/examples/pylab_examples/log_demo.html
http://matplotlib.org/1.3.0/examples/pylab_examples/legend_demo.html
http://stackoverflow.com/questions/19125722/adding-a-legend-to-pyplot-in-matplotlib-in-the-most-simple-manner-possible
http://stackoverflow.com/questions/4700614/how-to-put-the-legend-out-of-the-plot#4701285
@author: Rio
"""

import matplotlib.pyplot as plt
import numpy as np

with open("40years-frequency.dat") as f:
    data = f.read()

data = data.split('\n')

x = [row.split('  ')[0] for row in data]
y = [row.split('  ')[1] for row in data]

with open("40years-cores.dat") as f:
    data = f.read()

data = data.split('\n')

xx = [row.split('  ')[0] for row in data]
yy = [row.split('  ')[1] for row in data]

with open("40years-specint.dat") as f:
    data = f.read()

data = data.split('\n')

xxx = [row.split('  ')[0] for row in data]
yyy = [row.split('  ')[1] for row in data]

with open("40years-transistors.dat") as f:
    data = f.read()

data = data.split('\n')

xxxx = [row.split('  ')[0] for row in data]
yyyy = [row.split('  ')[1] for row in data]    

with open("40years-watts.dat") as f:
    data = f.read()

data = data.split('\n')

xxxxx = [row.split('  ')[0] for row in data]
yyyyy = [row.split('  ')[1] for row in data]     

plt.semilogy(x, y,'r-',label="Taktsagedus (MHz)")
plt.semilogy(xx, yy,'c-.',label="Tuumade arv protsessoris")
plt.semilogy(xxx, yyy,'-.',label = "Üksiku tuuma jõudlus (SpecInt x 10000)")
plt.semilogy(xxxx, yyyy,'g:',label = "Transistorite arv protsessoris")
plt.semilogy(xxxxx,yyyyy,'r,',label = "Energia kasutus (Watt)")
plt.legend( loc="upper left", prop={'size':8} )

plt.xlabel('Aastad')
plt.ylabel('')
plt.title('Mikroprotsessorite areng 40 aasta jooksul')
plt.grid(True)
plt.savefig("test.png")
plt.show()