Skip to content

Commit e0fa118

Browse files
committed
Ensure plot sends layout along.
I can’t believe that this wasn’t tested anywhere before!
1 parent 193f613 commit e0fa118

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

plotly/plotly/plotly.py

+1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ def plot(figure_or_data, validate=True, **plot_options):
214214

215215
fig = tools._replace_newline(figure) # does not mutate figure
216216
data = fig.get('data', [])
217+
plot_options['layout'] = fig.get('layout', {})
217218
response = v1.clientresp(data, **plot_options)
218219

219220
# Check if the url needs a secret key

plotly/tests/test_core/test_plotly/test_plot.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ def test_plot_valid(self):
4040
'x': [1, 2, 3],
4141
'y': [2, 1, 2]
4242
}
43-
]
43+
],
44+
'layout': {'title': 'simple'}
4445
}
45-
py.plot(fig, auto_open=False, filename='plot_valid')
46+
url = py.plot(fig, auto_open=False, filename='plot_valid')
47+
saved_fig = py.get_figure(url)
48+
self.assertEqual(saved_fig['data'][0]['x'], fig['data'][0]['x'])
49+
self.assertEqual(saved_fig['data'][0]['y'], fig['data'][0]['y'])
50+
self.assertEqual(saved_fig['layout']['title'], fig['layout']['title'])
4651

4752
@raises(PlotlyError)
4853
def test_plot_invalid(self):

0 commit comments

Comments
 (0)