Skip to content

Commit 6148b88

Browse files
committed
Don't break plotly.plot when passed a dict containing a Layout object
1 parent a1d5143 commit 6148b88

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plotly/plotly/plotly.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
from plotly import exceptions, files, session, tools, utils
3131
from plotly.api import v1, v2
32-
from plotly.basedatatypes import BaseTraceType, BaseFigure
32+
from plotly.basedatatypes import BaseTraceType, BaseFigure, BaseLayoutType
3333
from plotly.plotly import chunked_requests
3434

3535
from plotly.graph_objs import Scatter
@@ -146,6 +146,8 @@ def iplot(figure_or_data, **plot_options):
146146

147147
if isinstance(figure_or_data, dict):
148148
layout = figure_or_data.get('layout', {})
149+
if isinstance(layout, BaseLayoutType):
150+
layout = layout.to_plotly_json()
149151
elif isinstance(figure_or_data, BaseFigure):
150152
layout = figure_or_data.layout.to_plotly_json()
151153
else:
@@ -1851,6 +1853,8 @@ def icreate_animations(figure, filename=None, sharing='public', auto_open=False)
18511853

18521854
if isinstance(figure, dict):
18531855
layout = figure.get('layout', {})
1856+
if isinstance(layout, BaseLayoutType):
1857+
layout = layout.to_plotly_json()
18541858
elif isinstance(figure, BaseFigure):
18551859
layout = figure.layout.to_plotly_json()
18561860
else:

0 commit comments

Comments
 (0)