In [1]:
from bokeh.charts import Line, output_notebook, show
from bokeh.models import HoverTool, Legend
from bokeh.plotting import figure, ColumnDataSource
from bokeh.palettes import Spectral6
import pandas as pd
import numpy as np
from itertools import cycle
output_notebook()
In [2]:
df = pd.DataFrame(np.random.rand(10, 5), columns=['A', 'B', 'C', 'D', 'E'])
colors = Spectral6
colorcycler = cycle(colors)
source = ColumnDataSource(df)
p = figure(plot_width=800, plot_height=400)
for column in df.columns:
line = p.line(
x=df.index, y=column, source=source, legend="%s" % column,
line_color=next(colorcycler), line_width=5, line_cap='round', line_join='round'
)
p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("column", " %s" % column),], renderers=[line]))
show(p)
Out[2]:
In [ ]: