Currently I am working on an interactive plot using Jupyter notebook and ipywidgets, but I would like to be able to turn automatic updates of the graph on and off.
First I create a figure with a number of sliders to set the inputs, which are used to update about 15 different lines in 4 subplots. However, when I run the self.update_scatter() function, every time the whole graph is updated, which makes the update both a slow and ugly process.
What I want to do is to update all the lines in the background and then update the whole figure at once, but I cannot find a setting for this. Is it possible to turn off the automatic updates and manually update after I changed the graphs?
My update function looks like this:
def update_y_axis_old(change):
# Read data
[plot_data, axis_label, axis_val] = load_data()
# Some option to turn of automatic updates.....
# Update all traces.
for pol, col, row_no, in zip(['HH', 'HV'], ['blue', 'red'], [1, 2]):
# Plot amplitude plot
plot.update_traces(y=plot_data['percentiles_1_' + pol],
selector=dict(name= str(percentiles[1]) + ' percentile ' + pol), row=1, col=1)
plot.update_traces(y=plot_data['median_' + pol], selector=dict(name='amplitude ' + pol), row=1, col=1)
plot.update_traces(y=plot_data['percentiles_2_' + pol],
selector=dict(name= str(percentiles[0]) + ' percentile ' + pol), row=1, col=1)
# Plot coherence plots
plot.update_traces(y=plot_data['coherence_baseline_' + pol],
selector=dict(col=2, row=row_no, name='baseline'))
plot.update_traces(y=plot_data['coherence_vol_' + pol], selector=dict(name='volume'), col=2, row=row_no)
plot.update_traces(y=plot_data['coherence_snr_' + pol], selector=dict(name='SNR'), col=2, row=row_no)
plot.update_traces(y=plot_data['coh_percentiles_1_' + pol],
selector=dict(name= str(percentiles[0]) + ' percentile'), row=row_no, col=2)
plot.update_traces(y=plot_data['coherence_' + pol], selector=dict(name='total'), col=2, row=row_no)
plot.update_traces(y=plot_data['coh_percentiles_2_' + pol],
selector=dict(name= str(percentiles[1]) + ' percentile'), row=row_no, col=2)
# Plot std plot
for look in looks:
plot.update_traces(y=plot_data['std_meters_' + pol + '_' + str(look)],
selector=dict(name=pol + ' ' + str(look) + ' looks'), row=2, col=1)
# Finally do the update to the full plot.
I also tried some other ways to update the lines, but I get the same problem. The issue is here that plotly is updating the lines in the graph one by one, while I want to do the update all at once.