Plotting multiple lines with Bokeh and pandas

You need to provide a list of colors to multi_line. In your example, you would do, something like this:

p.multi_line(ts_list_of_list, vals_list_of_list, line_color=['red', 'green', 'blue'])

Here's a more general purpose modification of your second example that does more or less what you ended up with, but is a little more concise and perhaps more Pythonic:

import pandas as pd
import numpy as np
from bokeh.palettes import Spectral11
from bokeh.plotting import figure, show, output_file
output_file('temp.html')

toy_df = pd.DataFrame(data=np.random.rand(5,3), columns = ('a', 'b' ,'c'), index = pd.DatetimeIndex(start='01-01-2015',periods=5, freq='d'))   

numlines=len(toy_df.columns)
mypalette=Spectral11[0:numlines]

p = figure(width=500, height=300, x_axis_type="datetime") 
p.multi_line(xs=[toy_df.index.values]*numlines,
                ys=[toy_df[name].values for name in toy_df],
                line_color=mypalette,
                line_width=5)
show(p)

which yields:

multi_line plot


Maintainers note: The bokeh.charts API was deprecated and removed years ago



OBSOLETE:

You need to plot a Time Series chart. This will allow you to easily insert a legend. The TimeSeries attribute is could be located under bokeh._legacy_charts. Please see the following example located here:

http://docs.bokeh.org/en/0.9.3/docs/user_guide/charts.html