Skip to content

Commit ba49d75

Browse files
authored
Merge pull request #666 from plotly/ensure-layout-is-saved
Ensure `plot` sends layout along.
2 parents 02fb1c4 + e0fa118 commit ba49d75

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: plotly/plotly/plotly.py

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

221221
fig = tools._replace_newline(figure) # does not mutate figure
222222
data = fig.get('data', [])
223+
plot_options['layout'] = fig.get('layout', {})
223224
response = v1.clientresp(data, **plot_options)
224225

225226
# Check if the url needs a secret key

Diff for: plotly/tests/test_core/test_plotly/test_plot.py

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

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

0 commit comments

Comments
 (0)