Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬Register for the Oct 27 webinar.

Update plot with new data


I draw a plot with data which is two dimensional array (final_data) as following :

var data_z1 = {
z: final_data,
colorscale:[[‘0.0’, ‘rgb(255,0,0)’],[“0.25”, ‘rgb(255,255,0)’],[“0.5”, ‘rgb(0,255,0)’],[“0.75”, ‘rgb(0,255,255)’],[‘1.0’, ‘rgb(0,0,255)’]],
type: “contour”,

var layout = { … };

Plotly.newPlot(‘myDiv2D’, [data_z1], layout);

I need to update the plot (not redrawing) with adding some scatters, I did it like this :

var r1 = {x: [0, 80],y: [1, 1],type: ‘scatter’,hoverinfo: ‘none’,line: {color: ‘#000’,width: 1},marker: {symbol: ‘line-ne’},opacity: 1};

Plotly.newPlot(‘myDiv2D’, [data_z1, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, trace2,trace3,trace4,trace5], layout);

Is there a way to only update the plot without using Plotly.newPlot() because it’s too slow in my case.

Thank you so much in advance.

For your use case, you can try Plotly.addTraces: