Plotly.extendTraces is what you what to use.
Plotly.extendTraces
See previous post How to extend traces properly in js for an example.