Black Lives Matter. Please consider donating to Black Girls Code today.

Plotting/Animating a single candlestick

Hi
Im using python3.7 with the latest plotly library

using the Sample Code provided by plotly documents how would i change it ore add to it to have it instead of producing
5 different candles use the data to produce a single candle that changes(animate) with the new values instead of generating a new candle next to previous one

import plotly as py
import plotly.graph_objs as go

from datetime import datetime

open_data = [33.0, 33.3, 33.5, 33.0, 34.1]
high_data = [33.1, 33.3, 33.6, 33.2, 34.8]
low_data = [32.7, 32.7, 32.8, 32.6, 32.8]
close_data = [33.0, 32.9, 33.3, 33.1, 33.1]
dates = [datetime(year=2013, month=10, day=11)]

trace = go.Candlestick(x=dates,
                       open=open_data,
                       high=high_data,
                       low=low_data,
                       close=close_data)
data = [trace]
py.offline.plot(data, filename='candlestick_datetime')

Kind Regards
Deon Oosthuizen

Hi @DeonOosthuizen,

I think you’re best starting point is going to be the gapminder example (https://plot.ly/python/animations/#using-a-slider-and-buttons).

Basically you’ll need to create an array of frames (in layout.frames), where each frame has a single candlestick trace. (In this example, each frame has 5-traces so it’s a bit more complicated that your case needs to be).

Give that a try, and feel free to follow up if you get stuck :slightly_smiling_face:

-Jon

Thanks @jmmease

Ill give it look maybe it will work better than what i’m currently trying