20  Bokeh

# pip install bokeh
Collecting bokeh
  Downloading bokeh-3.5.1-py3-none-any.whl.metadata (12 kB)
Requirement already satisfied: Jinja2>=2.9 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from bokeh) (3.1.4)
Requirement already satisfied: contourpy>=1.2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from bokeh) (1.2.1)
Requirement already satisfied: numpy>=1.16 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from bokeh) (1.26.4)
Requirement already satisfied: packaging>=16.8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from bokeh) (24.0)
Requirement already satisfied: pandas>=1.2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from bokeh) (2.2.2)
Requirement already satisfied: pillow>=7.1.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from bokeh) (10.3.0)
Requirement already satisfied: PyYAML>=3.10 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from bokeh) (6.0.1)
Requirement already satisfied: tornado>=6.2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from bokeh) (6.4)
Collecting xyzservices>=2021.09.1 (from bokeh)
  Downloading xyzservices-2024.6.0-py3-none-any.whl.metadata (4.0 kB)
Requirement already satisfied: MarkupSafe>=2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from Jinja2>=2.9->bokeh) (2.1.5)
Requirement already satisfied: python-dateutil>=2.8.2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pandas>=1.2->bokeh) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pandas>=1.2->bokeh) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pandas>=1.2->bokeh) (2024.1)
Requirement already satisfied: six>=1.5 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from python-dateutil>=2.8.2->pandas>=1.2->bokeh) (1.16.0)
Downloading bokeh-3.5.1-py3-none-any.whl (6.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.8/6.8 MB 530.8 kB/s eta 0:00:00m eta 0:00:01[36m0:00:01
Downloading xyzservices-2024.6.0-py3-none-any.whl (83 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.9/83.9 kB 288.3 kB/s eta 0:00:00[36m0:00:01[36m0:00:01:01
Installing collected packages: xyzservices, bokeh
Successfully installed bokeh-3.5.1 xyzservices-2024.6.0

[notice] A new release of pip is available: 24.0 -> 24.2
[notice] To update, run: pip3.12 install --upgrade pip
Note: you may need to restart the kernel to use updated packages.
import pandas as pd
from bokeh.plotting import figure, output_notebook, show

output_notebook()
Loading BokehJS ...
f = '../data/Temixco_2018_10Min.csv'
tmx = pd.read_csv(f,parse_dates=["time"])
tmx
time Ib Ig To RH WS WD P
0 2018-01-01 00:00:00 NaN NaN 18.70 36.34 1.422 316.0 87864.11
1 2018-01-01 00:10:00 0.002 0.0 18.95 35.29 1.008 283.7 87876.37
2 2018-01-01 00:20:00 0.170 0.0 18.94 35.43 1.565 326.0 87888.64
3 2018-01-01 00:30:00 0.371 0.0 18.77 35.89 2.175 354.5 87887.21
4 2018-01-01 00:40:00 0.305 0.0 18.81 36.34 1.902 348.0 87886.91
... ... ... ... ... ... ... ... ...
52555 2018-12-31 23:10:00 0.125 0.0 18.51 47.29 1.715 332.2 87484.32
52556 2018-12-31 23:20:00 0.000 0.0 18.26 48.02 1.703 320.5 87470.70
52557 2018-12-31 23:30:00 0.044 0.0 18.39 46.84 2.887 335.7 87455.03
52558 2018-12-31 23:40:00 0.170 0.0 17.99 47.85 1.528 358.8 87470.02
52559 2018-12-31 23:50:00 0.003 0.0 17.75 49.65 0.598 322.3 87467.29

52560 rows × 8 columns

p = figure(
    x_axis_type='datetime',  # Asegura que Bokeh trate el eje x como fechas
    sizing_mode="stretch_width",# me permite ajustar al ancho de ventana
    height=150,
)

p.line(x='time', y='Ib', source=tmx, legend_label="Ib", color="blue")
p.line(x='time', y='Ig', source=tmx, legend_label="Ig", color="green")

# Activar la interactividad con la leyenda
p.legend.click_policy="hide"  # Permite ocultar/mostrar la serie al hacer clic en la leyenda

show(p)