Here is the code:
var trace1 = {
x: [1, 2, 3],
y: [40, 50, 60],
name: 'yaxis data',
type: 'scatter'
};
var trace2 = {
x: [2, 3, 4],
y: [4, 5, 6],
name: 'yaxis2 data',
yaxis: 'y2',
type: 'scatter'
};
var data = [trace1, trace2];
var layout = {
title: 'Double Y Axis Example',
yaxis: {title: 'yaxis title'},
yaxis2: {
title: 'yaxis2 title',
titlefont: {color: 'rgb(148, 103, 189)'},
tickfont: {color: 'rgb(148, 103, 189)'},
overlaying: 'y',
side: 'right'
}
};
Plotly.newPlot('myDiv', data, layout);
<head><script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head>
<div id="myDiv"></div>
I just want to update the data on the second axes yaxis2. I want to avoid the data redundancy, hence I do not want to forward the other data.
Please let me know what I can do.
trace2to something else, and re-plotting the data, while not replotting the data intrace1?Plot.reactplotly.com/javascript/plotlyjs-function-reference/#plotlyreact allows you to update by passing in a new array and doing a diff (so it won't redraw unchanged data). You could also usePlot.removeTracethen,Plot.addTraceto remove the data and readd it.