In [ ]:
import numpy as np
import pandas as pd
import bqplot.pyplot as plt
from datetime import datetime as dt
from bqplot.traits import convert_to_date
In [ ]:
price_data = pd.DataFrame(np.cumsum(np.random.randn(150, 2).dot([[0.5, 0.8], [0.8, 1.0]]), axis=0) + 100,
columns=['Security 1', 'Security 2'],
index=pd.date_range(start='01-01-2007', periods=150))
In [ ]:
x_data = price_data.index.values
In [ ]:
fig = plt.figure()
line = plt.plot(x=x_data, y=price_data['Security 1'])
fig
In [ ]:
import datetime
ref_date = datetime.datetime(2010, 1, 1)
num_items = range(250)
x_data = [ref_date + datetime.timedelta(x) for x in num_items]
date_x = convert_to_date(x_data)
In [ ]:
fig = plt.figure()
line = plt.plot(x=date_x, y=price_data['Security 1'])
fig
In [ ]:
x_data = np.array(x_data)
date_x = convert_to_date(x_data)
In [ ]:
fig = plt.figure()
line = plt.plot(x=date_x, y=price_data['Security 1'])
fig
In [ ]:
date_format = '%m-%d-%Y'
x_data = price_data.index.values
date_x = convert_to_date(x_data)
In [ ]:
fig = plt.figure()
line = plt.plot(x=date_x, y=price_data['Security 1'])
fig
In [ ]:
x_data = x_data.tolist()
In [ ]:
fig = plt.figure()
line = plt.plot(x=date_x, y=price_data['Security 1'])
fig
In [ ]:
date_format = '%m-%d-%Y'
x_data = price_data.index.values
data_2 = price_data.iloc[30: ,]
x_data_2 = data_2.index.values
In [ ]:
y_data = pd.concat([price_data['Security 1'], data_2['Security 2']], axis=1).values.T
In [ ]:
fig = plt.figure()
line = plt.plot(x=date_x, y=y_data, colors=['hotpink', 'orange'])
fig