Black Lives Matter. Please consider donating to Black Girls Code today.

BUG --> Unresolved: Clone Plot Without Losing JS Listeners

I’ve been attempting to duplicate a plot and there have some strange surprises that have appeared.

When I create the first plot, everything works fine, but when I go to export it by preparing a separate plot (I grab the data from the first plot and deep cloning it to avoid any references to the original data, I then make visual changes to the plot - background color, line width, etc.) a few things happen:

  1. The background color changes (sometimes, I haven’t been able to pinpoint why it happens or where)
  2. If the duplicate plot does modify the way I want, then when I zoom into the plot it reverts to the original setting
  3. Both plots are changed (to the settings defined for the second plot)

I have considered using the HTML cloneNode method to create a copy of the HTML itself, however, this isn’t an ideal solution because it would lose a lot of the JavaScript listeners Plotly has connected to the Plotly.js generated plots.

As plotly users, have you encountered this problem before? If so, how did you resolve it?

Can you provide a code snippet of your routine here to help us help you?

I’m experiencing a similar problem which is reproduced here. The second graph in my example is supposed to be the ‘clone’ of the first one with updated layout. However, when I zoom in the first graph, the updated layout applies to it as well which I don’t expect to occur. How can I avoid this behavior?

1 Like

@grendash Excellent example (thanks for providing one!)

This is the problem I described above. @etienne is there a solution or a workaround?