Dual-Axis Time-Series Plot#

A plot showing two time-series with different value ranges on separate y-axes. This is helpful when visualizing two related variables that have different units or scales.

Dual/twin axis is enabled with the multi_y plotting option made available by HoloViews (follow this issue to track its implementation in hvPlot directly). It is only supported by the Bokeh backend.

import pandas as pd
import numpy as np
import hvplot.pandas  # noqa

np.random.seed(0)
dates = pd.date_range("2024-01-01", periods=30, freq="D")
df = pd.DataFrame({
    'temperature': np.random.normal(25, 2, size=30),
    'humidity': np.random.uniform(60, 90, size=30)
}, index=dates)

temp = df.hvplot.line(y='temperature', ylabel='Temperature (°C)', label='Temperature')
humid = df.hvplot.line(y='humidity', ylabel='Humidity (%)', label='Humidity', color='green')

# Overlay with dual axes using multi_y option (only in Bokeh)
dual = (temp * humid).opts(multi_y=True, title="Temperature vs Humidity (Bokeh)")
dual
This web page was generated from a Jupyter notebook and not all interactivity will work on this website.