Created
February 6, 2019 17:22
-
-
Save andrewm4894/579315eca6a85336f2d93f9018aad498 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_lines_multi(df,lw=2,pw=700,ph=400,t_str="hover,save,pan,box_zoom,reset,wheel_zoom",t_loc='above'): | |
'''... | |
''' | |
source = ColumnDataSource(df) | |
col_names = source.column_names | |
p = figure(x_axis_type="datetime",plot_width=pw, plot_height=ph,toolbar_location=t_loc, tools=t_str) | |
p_dict = dict() | |
for col, c, col_name in zip(df.columns,color,col_names): | |
p_dict[col_name] = p.line('index', col, source=source, color=c,line_width=lw) | |
p.add_tools(HoverTool( | |
renderers=[p_dict[col_name]], | |
tooltips=[('datetime','@index{%Y-%m-%d %H:%M:%S}'),(col, f'@{col}')], | |
formatters={'index': 'datetime'} | |
)) | |
legend = Legend(items=[(x, [p_dict[x]]) for x in p_dict]) | |
p.add_layout(legend,'right') | |
show(p) | |
output_notebook() | |
plot_lines_multi(df._get_numeric_data()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@andrewm4894 I think line 8 should be
for col, c, col_name in zip(df.columns,color,col_names[1:]):
becausecol
andcol_name
are off by one