Create a dynamic chart to plot multiple axes and traces

Hallo ,

iam trying to create a webapplication where i can add and delete multiple y axes and traces.
I need 3 yaxis on each side maximum. But they should only appear when a button is pressed which adds a new trace that need
a new axis. How should i do this?

Adding new Trace is with Plotly.addTraces(div,data); no problem. But adding a new layout? i cannot find a way to create a new trace , specify the ‘Y’ axis and then create a new layout. The new layout with yaxis binded to the trace always need to get a new position when there is already one axis.

1 Like

Hmm. There’s only one layout per plot, so you can’t really add a new layout.

You can using Plotly.relayout to reposition the new x/y axes. For example:

Plotly.addTraces(gd, [{ y: [2, 1, 2], yaxis: 'y2', }]);
Plotly.relayout(gd, 'yaxis2.domain': [0.5, 1]);