Can't copy.deepcopy a Plotly figure
See original GitHub issueThis 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:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Done in https://github.com/plotly/plotly.py/pull/1191
ops, sorry @jonmmease for the confusion, thanks!