hvPlot 0.10 has just been released! Checkout the blog post and support hvPlot by giving it a 🌟 on Github.


import pandas as pd
import hvplot.pandas  # noqa

ohlc is a useful chart type to visualize stock movements

from bokeh.sampledata import stocks

df = pd.DataFrame(stocks.AAPL)
df['date'] = pd.to_datetime(df.date)


We can control the neg_color, pos_color, line_color and bar_width:

df.iloc[-50:].hvplot.ohlc(neg_color='indianred', pos_color='chartreuse', line_color='gray', bar_width=0.9, grid=True)

By default ohlc will assume the index OR the first datetime column should be mapped to the x-axis and the first four non-datetime columns correspond to the O (open), H (high), L (low) and C (close) components. The default call is therefore equivalent to:

df.iloc[-50:].hvplot.ohlc('date', ['open', 'low', 'high', 'close'], grid=True)

Using the HoloViews RangeToolLink we can make it easy to scroll through the data while still seeing an overview of the overall timeseries:

from holoviews.plotting.links import RangeToolLink

df_2012 = df[df.date > pd.to_datetime('2012')]

ohlc = df_2012.hvplot.ohlc(ylabel='Price ($)', grid=True, xaxis=None)
overview = df_2012.hvplot.ohlc(yaxis=None, height=150, fields={'date': 'Date'})
volume = df_2012.hvplot.step('date', 'volume', height=100, xaxis=None)

RangeToolLink(overview.get(0), ohlc.get(0))

layout = (volume + ohlc + overview).cols(1)