From e0fa1181e153862393f11ab9cd960965490a6f3e Mon Sep 17 00:00:00 2001 From: Andrew Seier Date: Tue, 17 Jan 2017 15:53:59 -0800 Subject: [PATCH] Ensure `plot` sends layout along. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I can’t believe that this wasn’t tested anywhere before! --- plotly/plotly/plotly.py | 1 + plotly/tests/test_core/test_plotly/test_plot.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plotly/plotly/plotly.py b/plotly/plotly/plotly.py index bd1191fb30d..506232a84f2 100644 --- a/plotly/plotly/plotly.py +++ b/plotly/plotly/plotly.py @@ -214,6 +214,7 @@ def plot(figure_or_data, validate=True, **plot_options): fig = tools._replace_newline(figure) # does not mutate figure data = fig.get('data', []) + plot_options['layout'] = fig.get('layout', {}) response = v1.clientresp(data, **plot_options) # Check if the url needs a secret key diff --git a/plotly/tests/test_core/test_plotly/test_plot.py b/plotly/tests/test_core/test_plotly/test_plot.py index 77e9c84d6b3..a01b1b3a138 100644 --- a/plotly/tests/test_core/test_plotly/test_plot.py +++ b/plotly/tests/test_core/test_plotly/test_plot.py @@ -40,9 +40,14 @@ def test_plot_valid(self): 'x': [1, 2, 3], 'y': [2, 1, 2] } - ] + ], + 'layout': {'title': 'simple'} } - py.plot(fig, auto_open=False, filename='plot_valid') + url = py.plot(fig, auto_open=False, filename='plot_valid') + saved_fig = py.get_figure(url) + self.assertEqual(saved_fig['data'][0]['x'], fig['data'][0]['x']) + self.assertEqual(saved_fig['data'][0]['y'], fig['data'][0]['y']) + self.assertEqual(saved_fig['layout']['title'], fig['layout']['title']) @raises(PlotlyError) def test_plot_invalid(self):