question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't copy.deepcopy a Plotly figure

See original GitHub issue

This does not work:

>>> from copy import deepcopy
>>> import plotly.graph_objs as go
>>> figure = go.Figure(data=[go.Scatter(x=[1,2,3], y=[1,2,3])], layout=go.Layout())
>>> deepcopy(figure)

and gives the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 280, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 281, in _reconstruct
    if hasattr(y, '__setstate__'):
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3537, in __getattr__
    if prop in self._subplotid_props:
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3537, in __getattr__
    if prop in self._subplotid_props:
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3537, in __getattr__
    if prop in self._subplotid_props:
  [Previous line repeated 490 more times]
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3536, in __getattr__
    prop = self._strip_subplot_suffix_of_1(prop)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3504, in _strip_subplot_suffix_of_1
    prop_tuple = BaseFigure._str_to_dict_path(prop)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 745, in _str_to_dict_path
    if isinstance(key_path_str, string_types) and \
RecursionError: maximum recursion depth exceeded while calling a Python object

I am using plotly==3.1.0 and Python==3.7.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jonmmeasecommented, Sep 26, 2018
0reactions
shllgtcacommented, Jul 28, 2020

ops, sorry @jonmmease for the confusion, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to copy Figure or Trace object? Deepcopy no longer ...
I'm trying to create a copy for caching purposes, so I can load and make slight modifications to some traces without generating a...
Read more >
How to make a copy of a plotly figure object? - Stack Overflow
Like the error message says, fig1 or go.Figure() does not have a copy functionality or attribute. The solution is easy though; just make ......
Read more >
Methods for updating the figure or graph objects - maegul
Sometimes the easiest way to edit the parameters of a graph is to print out the full figure dictionary, edit it as desired,...
Read more >
Plotly Dash Development Tips | Mátyás Budavári
Then run a search for all unique occurances of the plotly events that were sent with emit by using ag, the silver seracher....
Read more >
holoviews.plotting.plotly.dash — HoloViews v1.15.2
standard library imports import uuid import copy from collections import ... Convert a HoloViews plotly plot to a plotly.py Figure.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found