Plotly.update - changing attributes in the data array

I’m using Plotly.update to change attributes in the data array, and as a newcomer here, I’m finding it difficult to change 2 different attributes to 2 different traceIndices.

Example; I have 4 different traces, and I want to change trace’s 1 & 3 to display as green, so I set;
{ "marker.color": "green" } and the traceIndices to [1, 3] and yes that works fine.

But if I also at the same time want to change trace’s 2 & 4 to be bars, I don’t know how to combine the 2 changes, and direct each change to the respective traceIndices.

Any help appreciated

EDIT - I’m using javascript, not python.

Hi i have a dash custom component to do that.

You can check the javascript code from:

Thanks @danielT43 but that looks like a complicated solution for what should be a simple problem…

Is there no way that this can be achieved using the existing Plotly framework.

I’d be surprised if I were the first to ask.

Well, honestly i don’t know javascript. All i know is that you can delete the trace and then update it.
You can use Plotly.DeleteTrace to remove all your traces in the graph and then add the new ones (with different attributes) with Plotly.AddTrace. Then with Plotly.Restyle you will update your traces faster than Plotly.Update

You need two updates, something like that

Plotly.update(myplot, { “marker.color”: “green” }, {}, [1, 3])
Plotly.update(myplot, { “marker.color”: “red” }, {}, [2, 4])