# encoding: utf-8

##################################################
# This script shows how to create animated plots using matplotlib and a basic dataset
# Multiple tutorials inspired the current design but they mostly came from:
# https://towardsdatascience.com/animations-with-matplotlib-d96375c5442c
# Note: the project keeps updating every course almost yearly
##################################################
#
##################################################
# Author: Diego Pajarito
# Credits: [Institute for Advanced Architecture of Catalonia - IAAC, Advanced Architecture group]
# License:  Apache License Version 2.0
# Version: 1.0.0
# Maintainer: Diego Pajarito
# Email: diego.pajarito@iaac.net
# Status: development
##################################################

# We need to import numpy and matplotlib library
# importing libraries
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig = plt.figure()
# creating a subplot
ax1 = fig.add_subplot(1, 1, 1)


def animate(i):
    data = open('../data/animation_input.txt', 'r').read()
    lines = data.split('\n')
    xs = []
    ys = []

    for line in lines:
        x, y = line.split(',')  # Delimiter is comma
        xs.append(float(x))
        ys.append(float(y))

    ax1.clear()
    ax1.plot(xs, ys)

    plt.xlabel('Date')
    plt.ylabel('Price')
    plt.title('Live graph with matplotlib')


ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()

4881e80f80a3527b1895d32d25a99d8c40955dbe
<mask token>


def animate(i):
    data = open('../data/animation_input.txt', 'r').read()
    lines = data.split('\n')
    xs = []
    ys = []
    for line in lines:
        x, y = line.split(',')
        xs.append(float(x))
        ys.append(float(y))
    ax1.clear()
    ax1.plot(xs, ys)
    plt.xlabel('Date')
    plt.ylabel('Price')
    plt.title('Live graph with matplotlib')


<mask token>

<mask token>


def animate(i):
    data = open('../data/animation_input.txt', 'r').read()
    lines = data.split('\n')
    xs = []
    ys = []
    for line in lines:
        x, y = line.split(',')
        xs.append(float(x))
        ys.append(float(y))
    ax1.clear()
    ax1.plot(xs, ys)
    plt.xlabel('Date')
    plt.ylabel('Price')
    plt.title('Live graph with matplotlib')


<mask token>
plt.show()

<mask token>
fig = plt.figure()
ax1 = fig.add_subplot(1, 1, 1)


def animate(i):
    data = open('../data/animation_input.txt', 'r').read()
    lines = data.split('\n')
    xs = []
    ys = []
    for line in lines:
        x, y = line.split(',')
        xs.append(float(x))
        ys.append(float(y))
    ax1.clear()
    ax1.plot(xs, ys)
    plt.xlabel('Date')
    plt.ylabel('Price')
    plt.title('Live graph with matplotlib')


ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()

import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig = plt.figure()
ax1 = fig.add_subplot(1, 1, 1)


def animate(i):
    data = open('../data/animation_input.txt', 'r').read()
    lines = data.split('\n')
    xs = []
    ys = []
    for line in lines:
        x, y = line.split(',')
        xs.append(float(x))
        ys.append(float(y))
    ax1.clear()
    ax1.plot(xs, ys)
    plt.xlabel('Date')
    plt.ylabel('Price')
    plt.title('Live graph with matplotlib')


ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()

# encoding: utf-8

##################################################
# This script shows how to create animated plots using matplotlib and a basic dataset
# Multiple tutorials inspired the current design but they mostly came from:
# https://towardsdatascience.com/animations-with-matplotlib-d96375c5442c
# Note: the project keeps updating every course almost yearly
##################################################
#
##################################################
# Author: Diego Pajarito
# Credits: [Institute for Advanced Architecture of Catalonia - IAAC, Advanced Architecture group]
# License:  Apache License Version 2.0
# Version: 1.0.0
# Maintainer: Diego Pajarito
# Email: diego.pajarito@iaac.net
# Status: development
##################################################

# We need to import numpy and matplotlib library
# importing libraries
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig = plt.figure()
# creating a subplot
ax1 = fig.add_subplot(1, 1, 1)


def animate(i):
    data = open('../data/animation_input.txt', 'r').read()
    lines = data.split('\n')
    xs = []
    ys = []

    for line in lines:
        x, y = line.split(',')  # Delimiter is comma
        xs.append(float(x))
        ys.append(float(y))

    ax1.clear()
    ax1.plot(xs, ys)

    plt.xlabel('Date')
    plt.ylabel('Price')
    plt.title('Live graph with matplotlib')


ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()
