Reputation: 43
I discovered Plotly for plotting candlestick chart and I tried to use it for plotting SPX 1 mins chart. I noticed extremely slow response time of the output graph (label pop up and zoom-in/out, etc) when trying to feed a whole year of 1-min OHLC data into (over 300k rows).
I just used the example code from Plotly website cause I am not a programmer,
import plotly.graph_objects as go
import pandas as pd
df = pd.read_csv('file:///Users/jacliu2/Downloads/DAT_XLSX_SPXUSD_M1_2021.csv')
fig = go.Figure(data=[go.Candlestick(x=df['Date'],
open=df['SPX.Open'], high=df['SPX.High'],
low=df['SPX.Low'], close=df['SPX.Close'])
])
fig.update_layout(xaxis_rangeslider_visible=False)
fig.show()
Is there any way to improve the performance and response time of Plotly so I can use it to plot 1-min candlestick graph for 1 year time frame?
Or how can I get the code to allow me to select specific date/time so Plotly can plot specific time frame only to avoid such lagging when it trying to plot a whole year in one go?
Upvotes: 2
Views: 6327
Reputation: 19610
All of the data is stored inside the html/javascript the moment you pass the df
to fig
so the responsiveness is going to be limited by the size of the df unfortunately.
To be honest, I don't think this will lead to much an improvement in response time, but you can try downsizing the df if you are okay with reducing the precision of the floats in the plot. 300k rows with four different values is a lot for the plotly renderer to handle.
Upvotes: 2