<jupyter_start><jupyter_text>Interactive Charts - Bokeh    Interactive Bokeh - Main Hiding Glyphs<jupyter_code>from bokeh.palettes import Spectral4
from bokeh.plotting import figure, output_file, show
from bokeh.sampledata.stocks import AAPL, GOOG, IBM, MSFT

import pandas as pd
local_output_folder = "visuals-html"
joiner = lambda filename, folder=local_output_folder: rf"{folder}\{filename}"
data = [AAPL, GOOG, IBM, MSFT]

p = figure(plot_width=800, plot_height=250, x_axis_type="datetime")
p.title.text = "Click ticker name in legend to hide data"

for data, name, color in zip([AAPL, GOOG, IBM, MSFT], ["AAPL", "GOOG", "IBM", "MSFT"], Spectral4):
    df = pd.DataFrame(data)
    df.loc[:, "date"] = pd.to_datetime(df.loc[:, "date"])
    p.line(df.loc[:, "date"], df.loc[:, "close"], line_width=2, color=color, alpha=0.8, legend_label=name)
    
p.legend.location = "top_left"
p.legend.click_policy="hide"

output_file(joiner("stocks-1.html"), title="Interactive Plot Example")

show(p)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15181194906953965, 'fraction_numerical': 0.011753183153770812, 'mean_word_length': 5.905405405405405, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '494291', 'license': 'MIT', 'n_tokens_mistral': 392, 'n_tokens_neox': 389, 'n_words': 89, 'path': 'notebook-samples/.ipynb_checkpoints/bokeh-stocks-hide-show-checkpoint.ipynb', 'repo_name': 'MarkMoretto/python-examples-main', 'size': '1021'}