# -*- coding: utf-8 -*-
"""
Created on Thu Sep 17 21:33:24 2015

@author: Tillsten
"""
import matplotlib
import matplotlib.pyplot as plt
import numpy as np

tableau20 = [(31, 119, 180), (174, 199, 232), (255, 127, 14), (255, 187, 120),
             (44, 160, 44), (152, 223, 138), (214, 39, 40), (255, 152, 150),
             (148, 103, 189), (197, 176, 213), (140, 86, 75), (196, 156, 148),
             (227, 119, 194), (247, 182, 210), (127, 127, 127), (199, 199, 199),
             (188, 189, 34), (219, 219, 141), (23, 190, 207), (158, 218, 229)]

tableau20 = [(r/255., g/255., b/255.) for r,g,b, in tableau20]

#plt.rcParams['savefig.dpi'] = 110
#plt.rcParams['font.family'] = 'Vera Sans'

out_ticks = {'xtick.direction': 'out',
             'xtick.major.width': 1.5,
             'xtick.minor.width': 1,
             'xtick.major.size': 6,
             'xtick.minor.size': 3,
             'xtick.minor.visible': True,
             'ytick.direction': 'out',
             'ytick.major.width': 1.5,
             'ytick.minor.width': 1,
             'ytick.major.size': 6,
             'ytick.minor.size': 3,
             'ytick.minor.visible': True,
             'axes.spines.top': False,
             'axes.spines.right': False,
             'text.hinting': True,
             'axes.titlesize': 'xx-large',
             'axes.titleweight': 'semibold',
             }


plt.figure(figsize=(6,4))

with plt.style.context(out_ticks):
    ax = plt.subplot(111)
    x = np.linspace(0, 7, 1000)
    y = np.exp(-x/1.5)*np.cos(x/1*(2*np.pi))#*np.cos(x/0.05*(2*np.pi))
    l, = plt.plot(x, np.exp(-x/1.5), lw=0.5, color='grey')
    l, = plt.plot(x, -np.exp(-x/1.5), lw=0.5, color='grey')
    l, = plt.plot(x, y, lw=1.1)
    #l.set_clip_on(0)
    plt.tick_params(which='both', top=False, right=False)
    plt.margins(0.01)
    ax.text(7, 1, r'$y(t)=\exp\left(-t/1.5\right)\cos(\omega_1t)\cos(\omega_2t)$',
             fontsize=18, va='top', ha='right')
    #plt.title("Hallo")
    plt.setp(plt.gca(), xlabel='Time [s]', ylabel='Amplitude')
    ax = plt.axes([0.57, 0.25, 0.3, .2])
    #ax.plot(np.fft.fftfreq(x.size)[:y.size/2], abs(np.fft.fft(y))[:y.size/2])
    ax.fill_between(np.fft.fftfreq(x.size, x[1]-x[0])[:y.size/2],
                    abs(np.fft.fft(y))[:y.size/2], alpha=0.2, color='r')
    ax.set_xlim(0, 10)
    ax.set_xlabel("Frequency")
    ax.xaxis.labelpad = 1

    plt.locator_params(nbins=4)
    plt.tick_params(which='both', top=False, right=False)
    plt.tick_params(which='minor', bottom=False, left=False)

    #plt.grid(1, axis='y', linestyle='-', alpha=0.3, lw=.5)
plt.show()

[((42, 0, 42, 25), 'matplotlib.pyplot.figure', 'plt.figure', (), '', True, 'import matplotlib.pyplot as plt\n'), ((71, 0, 71, 10), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((44, 5, 44, 33), 'matplotlib.pyplot.style.context', 'plt.style.context', ({(44, 23, 44, 32): 'out_ticks'}, {}), '(out_ticks)', True, 'import matplotlib.pyplot as plt\n'), ((45, 9, 45, 25), 'matplotlib.pyplot.subplot', 'plt.subplot', ({(45, 21, 45, 24): '111'}, {}), '(111)', True, 'import matplotlib.pyplot as plt\n'), ((46, 8, 46, 31), 'numpy.linspace', 'np.linspace', ({(46, 20, 46, 21): '0', (46, 23, 46, 24): '7', (46, 26, 46, 30): '1000'}, {}), '(0, 7, 1000)', True, 'import numpy as np\n'), ((50, 9, 50, 31), 'matplotlib.pyplot.plot', 'plt.plot', (), '', True, 'import matplotlib.pyplot as plt\n'), ((52, 4, 52, 57), 'matplotlib.pyplot.tick_params', 'plt.tick_params', (), '', True, 'import matplotlib.pyplot as plt\n'), ((53, 4, 53, 21), 'matplotlib.pyplot.margins', 'plt.margins', ({(53, 16, 53, 20): '(0.01)'}, {}), '(0.01)', True, 'import matplotlib.pyplot as plt\n'), ((58, 9, 58, 40), 'matplotlib.pyplot.axes', 'plt.axes', ({(58, 18, 58, 39): '[0.57, 0.25, 0.3, 0.2]'}, {}), '([0.57, 0.25, 0.3, 0.2])', True, 'import matplotlib.pyplot as plt\n'), ((66, 4, 66, 31), 'matplotlib.pyplot.locator_params', 'plt.locator_params', (), '', True, 'import matplotlib.pyplot as plt\n'), ((67, 4, 67, 57), 'matplotlib.pyplot.tick_params', 'plt.tick_params', (), '', True, 'import matplotlib.pyplot as plt\n'), ((68, 4, 68, 60), 'matplotlib.pyplot.tick_params', 'plt.tick_params', (), '', True, 'import matplotlib.pyplot as plt\n'), ((47, 8, 47, 22), 'numpy.exp', 'np.exp', ({(47, 15, 47, 21): '(-x / 1.5)'}, {}), '(-x / 1.5)', True, 'import numpy as np\n'), ((47, 23, 47, 44), 'numpy.cos', 'np.cos', ({(47, 30, 47, 43): '(x / 1 * (2 * np.pi))'}, {}), '(x / 1 * (2 * np.pi))', True, 'import numpy as np\n'), ((48, 21, 48, 35), 'numpy.exp', 'np.exp', ({(48, 28, 48, 34): '-x / 1.5'}, {}), '(-x / 1.5)', True, 'import numpy as np\n'), ((57, 13, 57, 22), 'matplotlib.pyplot.gca', 'plt.gca', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((49, 22, 49, 36), 'numpy.exp', 'np.exp', ({(49, 29, 49, 35): '-x / 1.5'}, {}), '(-x / 1.5)', True, 'import numpy as np\n'), ((60, 20, 60, 53), 'numpy.fft.fftfreq', 'np.fft.fftfreq', ({(60, 35, 60, 41): 'x.size', (60, 43, 60, 52): '(x[1] - x[0])'}, {}), '(x.size, x[1] - x[0])', True, 'import numpy as np\n'), ((61, 24, 61, 37), 'numpy.fft.fft', 'np.fft.fft', ({(61, 35, 61, 36): 'y'}, {}), '(y)', True, 'import numpy as np\n')]