Closed
Description
Example:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import plotly.graph_objs as go
import plotly.offline as py
import datetime
n = 20
open = 2 + np.abs(np.random.randn(n))
high = open + 1
low = open - 1
close = open + np.random.randn(n)
df = pd.DataFrame(
{
'open': open,
'high': high,
'low': low,
'close': close
},
index=pd.date_range(
'2010-01-01',
pd.to_datetime('2010-01-01') + datetime.timedelta(days=n - 1)))
hovertext = []
for i in range(len(df.open)):
hovertext.append('Point' + str(i))
trace = go.Candlestick(
x=df.index,
open=df.open,
high=df.high,
low=df.low,
close=df.close,
text=hovertext,
hoverinfo='all')
data = [trace]
py.plot(data, filename='ohlc_custom_hover.html')
However, turning the line trace = go.Candlestick(
to trace = go.Ohlc(
works just fine.
The plotly version is 2.2.3
.