I am trying to input a single file that contains data from different packet streams (hence, different time values). I created a dataframe for each time and the data points/columns from each dataframe are plotted in single plot. I am not being able to get how to append the items in the legend to reflect the correct col names in the loop. This is what I have so far:
j = 0
tabs_df_list = []
## Creating source and figures for each df
for x in df_list:
j += 1
df_col_names = x.columns.to_numpy()
col_names = df_col_names.tolist()
source = "source"+str(j)
source = ColumnDataSource(x)
## Create a figure for each df
p = "p" + str(j)
p = figure(title = 'Test Tlm Report',
match_aspect = False,
toolbar_location = 'right',
height=750, width=1000,
x_axis_label = 'Time [hh:mm]', # needs to correct time series
y_axis_label = 'Data value') # need to customize to tlm col
tabs_temp = []
items_list = []
k = 1
while k < len(col_names):
r = "r" + str(k)
r = p.line(x=col_names[0], y=col_names[k], source=source, line_width=2, line_color="lightseagreen", name=col_names[k], legend_label=col_names[k])
r = p.scatter(x=col_names[0], y=col_names[k], source=source)
items_list.append(col_names[k])
items_list.append(r)
tab = [TabPanel(child=p, title=col_names[0])]
k += 1
p.add_tools(HoverTool(tooltips=tooltips))
legend = Legend(items=[items_list
],location=(3, -25))
p.add_layout(legend, 'right')
p.legend.click_policy="mute"
tabs_df = "tabss" + str(j)
tabs_df = Tabs(tabs=tab)
tabs_df_list.append(tabs_df)
grid = gridplot (tabs_df_list, ncols=1)
show (grid)
The items list in the legend is what I do not know how to dynamically add to =/
