Unable to update the shape using relayout

After ploting my data using .newPlot, I would like to update the layout adding a shape.
So instead of using .newPlot to update my layout, I was thinking that .relayout was appropriate but it does not seem to update my layout with the shape.

I have uploaded an example, is there something wrong using .relayout in this case ?


Is there a workaround except using .newPlot again ?

relayout doesn’t expect a new layout object. It expect, a set of key-values updates. (We probably should make that clear here by the way).

So, in your case:

Plotly.relayout('myDiv', {
  'shapes[0]': {
      type: 'path',
      path: ' M 3,7 L2,8 L2,9 L3,10, L4,10 L5,9 L5,8 L4,7 Z',
      line: {
        color: 'rgb(255, 140, 184)'

should do the trick.

Thank you very much. I misunderstood the use of the relayout function !

@etienne How to remove a shape with Javascript?
Should we use relayout?