Hi @batdan,
Based on reading your code, I would have expected the plotly.offline.plot
call to be taking up most of the time. In my experience the go.Figure
constructor call can get slow with lots of traces, but if you have only a few traces with lots of data then the long pole is typically the call to *.plot
/*.iplot
. Could you time go.Figure(...)
and plotly.offline.plot
separately?
The main reason that plotly.offline.plot
gets slow for large arrays is that the array gets serialized to a JSON list. If youβre working in the Jupyter notebook you can display the figure as a go.FigureWidget
instance (https://plot.ly/python/figurewidget/), in which case the large arrays are transfered to the JavaScript library as binary buffers, which is a lot faster.
If the go.Figure
call by itself is the slow part, you can bypass the validation work that the graph_objs
objects do by defining you figure in terms of raw dict
and list
instances. Then you can set the validate=False
argument to plotly.offline.plot
to skip validation. Something like
trace1 = dict(x=alldata['datetime'], y=alldata['a_gpib_alt_power_w'],
name='A Alt Power', yaxis='y2', mode = 'lines+markers',
line = dict(width = 1, color = '#1f77b4'),
marker = dict(size = 2, color = '#1f77b4')) #muted blue
trace2 = dict(x=alldata['datetime'], y=alldata['b_gpib_alt_power_w'],
name='B Alt Power', yaxis='y2', mode = 'lines+markers',
line = dict(width = 1, color = '#17becf'),
marker = dict(size= 2, color = '#17becf')) #blue-teal
trace3 = dict(x=alldata['datetime'], y=alldata['ambient_tc_c'],
name='Ambient Temp', yaxis='y3', mode = 'lines+markers',
line = dict(width = 1, color = '#ff7f0e'),
marker = dict(size = 2, color = '#ff7f0e')) # safety orange
data = [trace1, trace2, trace3]
layout = dict(
xaxis=dict(
autorange=False,
range=[alldata['datetime'].min(), alldata['datetime'].max()]
)
#this is the function that I profiled in the original post.
fig = dict(data=data, layout=layout)
plotly.offline.plot(fig, filename=convertorname+'_weekly.html', auto_open=False, validate=False)
-Jon