Я пытаюсь наложить графики боке.
Этот сверху: http://docs.bokeh.org/en/latest/docs/gallery/image_rgba.html
и этот внизу: http://docs.bokeh.org/en/latest/docs/gallery/stocks.html
или наоборот.
Я меняю ось x на datetime, чтобы соответствовать графику запаса. Но пока это пустая диаграмма. Какие-либо предложения?
import numpy as np
import arrow
import pandas as pd
import pandas.io.data as web
#from pandas_data_reader import data as web
from pandas import DataFrame, Series
from bokeh.io import output_notebook
output_notebook()
from bokeh.plotting import figure, show, output_file, gridplot
p1 = figure(x_axis_type = "datetime", responsive=True)
N = 100
M = 100
img = np.empty((N,M), dtype=np.uint32)
view = img.view(dtype=np.uint8).reshape((N, M, 4))
for i in range(N):
for j in range(M):
view[i, j, 0] = 0 #red
view[i, j, 1] = int(i/N*160) #green
view[i, j, 2] = int(j/N*255) #blue
view[i, j, 3] = int(i/N*255) #alpha
p1 = figure(x_range=['10/1/2015','11/1/2015'], y_range=[0,200]) #changes the view window
all_data = {}
for ticker in ['AAPL', 'IBM', 'MSFT', 'GOOG']:
all_data[ticker] = web.get_data_google(ticker, '10/1/2015', '11/1/2015')
AAPL = Series(all_data['AAPL']['Close'])
GOOG = Series(all_data['GOOG']['Close'])
MSFT = Series(all_data['MSFT']['Close'])
IBM = Series(all_data['IBM']['Close'])
p1.line(AAPL.index, AAPL, color='#A6CEE3', legend='Apple')
p1.line(IBM.index, IBM, color='#0022CC', legend='IBM')
p1.line(MSFT.index, MSFT, color='#3322DD', legend='MICROSOFT')
p1.title = "Superimposed info"
p1.image_rgba(image=[img], x=['10/1/2015'], y=[10], dw=['10/15/2015'], dh=[10])
p = gridplot([[p1]], toolbar_location=None, min_border=0, h_symmetry=True)
show(p)