diff --git a/plotly/basedatatypes.py b/plotly/basedatatypes.py index a792652b83e..799cd41fc48 100644 --- a/plotly/basedatatypes.py +++ b/plotly/basedatatypes.py @@ -1,6 +1,7 @@ from __future__ import absolute_import import collections +from collections import OrderedDict import re import six from six import string_types @@ -233,14 +234,14 @@ class is a subclass of both BaseFigure and widgets.DOMWidget. # are suitable as `data` elements of Plotly.animate, but not # the Plotly.update (See `_build_update_params_from_batch`) # - # type: typ.Dict[int, typ.Dict[str, typ.Any]] - self._batch_trace_edits = {} + # type: OrderedDict[int, OrderedDict[str, typ.Any]] + self._batch_trace_edits = OrderedDict() # ### Batch layout edits ### # Dict from layout properties to new layout values. This dict is # directly suitable for use in Plotly.animate and Plotly.update - # type: typ.Dict[str, typ.Any] - self._batch_layout_edits = {} + # type: collections.OrderedDict[str, typ.Any] + self._batch_layout_edits = OrderedDict() # Animation property validators # ----------------------------- @@ -772,7 +773,7 @@ def _restyle_child(self, child, key_path_str, val): # Add key_path_str/val to saved batch edits else: if trace_index not in self._batch_trace_edits: - self._batch_trace_edits[trace_index] = {} + self._batch_trace_edits[trace_index] = OrderedDict() self._batch_trace_edits[trace_index][key_path_str] = val def _normalize_trace_indexes(self, trace_indexes): diff --git a/plotly/tests/test_core/test_graph_objs/test_layout_subplots.py b/plotly/tests/test_core/test_graph_objs/test_layout_subplots.py index bf9ed87ed09..1530db58ab8 100644 --- a/plotly/tests/test_core/test_graph_objs/test_layout_subplots.py +++ b/plotly/tests/test_core/test_graph_objs/test_layout_subplots.py @@ -208,3 +208,20 @@ def test_create_subplot_with_update_dict(self): self.assertEqual(self.layout.scene6.dragmode, 'zoom') self.assertEqual(self.layout.mapbox7.zoom, 2) self.assertEqual(self.layout.polar8.sector, (0, 90)) + + def test_bug_1462(self): + # https: // github.com / plotly / plotly.py / issues / 1462 + fig = go.Figure(data=[ + go.Scatter(x=[1, 2], y=[1, 2], xaxis='x'), + go.Scatter(x=[2, 3], y=[2, 3], xaxis='x2')]) + + layout_dict = { + 'grid': {'xaxes': ['x', 'x2'], 'yaxes': ['y']}, + # 'xaxis': {'title': 'total_bill'}, + 'xaxis2': {'matches': 'x', 'title': {'text': 'total_bill'}} + } + + fig.update(layout=layout_dict) + updated_layout_dict = fig.layout.to_plotly_json() + + self.assertEqual(updated_layout_dict, layout_dict)