OHLC Plot with Interactive Range Tool#

An OHLC (Open–High–Low–Close) plot displaying stock price movements for Apple Inc. This example uses HoloViews to add a range slider that helps exploring long time series.

import hvplot.pandas  # noqa
import pandas as pd
from holoviews.plotting.links import RangeToolLink

df = hvplot.sampledata.apple_stocks("pandas").set_index("date").loc["2020-01-01":]

# Main OHLC plot
ohlc_plot = df.hvplot.ohlc(
    ylabel='Price ($)',
    grid=True,
    width=700,
    height=300,
)
# Overview OHLC plot for interactive range selection
overview = df.hvplot.ohlc(
    width=700,
    height=100,
    ylabel='',
    xaxis=None,
    yaxis=None,
    hover=False,
    ylim=(0, 100),
)
# Link the range between overview and main plot
RangeToolLink(
    overview,
    ohlc_plot,
    boundsx=(pd.Timestamp("2023-01-01"), pd.Timestamp("2023-06-30")),
)

# Stack the plots vertically
(ohlc_plot + overview).cols(1)
This web page was generated from a Jupyter notebook and not all interactivity will work on this website.