# Buggy code
def crawl_legend(self, ax, legend):
    """
    Recursively look through objects in legend children
    """
    legendElements = list(
        utils.iter_all_children(legend._legend_box, skipContainers=True)
    )
    legendElements.append(legend.legendPatch)
    for child in legendElements:
        # force a large zorder so it appears on top
        child.set_zorder(1e6 + child.get_zorder())

        try:
            # What kind of object...
            if isinstance(child, matplotlib.patches.Patch):
                self.draw_patch(ax, child, force_trans=ax.transAxes)
            elif isinstance(child, matplotlib.text.Text):
                if not (
                    child is legend.get_children()[-1] and child.get_text() == "None"
                ):
                    self.draw_text(ax, child, force_trans=ax.transAxes)
            elif isinstance(child, matplotlib.lines.Line2D):
                self.draw_line(ax, child, force_trans=ax.transAxes)
            elif isinstance(child, matplotlib.collections.Collection):
                self.draw_collection(ax, child, force_pathtrans=ax.transAxes)
            else:
                warnings.warn("Legend element %s not impemented" % child)
        except NotImplementedError:
            warnings.warn("Legend element %s not impemented" % child)


# Traceback (TypeError)
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/plotly/plotly/plotly.py", line 241, in plot
res = _send_to_plotly(figure, **plot_options)
File "/Library/Python/2.7/site-packages/plotly/plotly/plotly.py", line 1374, in _send_to_plotly
cls=utils.PlotlyJSONEncoder)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 250, in dumps
sort_keys=sort_keys, **kw).encode(obj)
File "/Library/Python/2.7/site-packages/plotly/utils.py", line 145, in encode
encoded_o = super(PlotlyJSONEncoder, self).encode(o)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/Library/Python/2.7/site-packages/plotly/utils.py", line 211, in default
return json.JSONEncoder.default(self, obj)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: Decimal('-94.6285553000') is not JSON serializable

# Fixed code
def crawl_legend(self, ax, legend):
    """
    Recursively look through objects in legend children
    """
    legendElements = list(
        utils.iter_all_children(legend._legend_box, skipContainers=True)
    )
    legendElements.append(legend.legendPatch)
    for child in legendElements:
        # force a large zorder so it appears on top
        child.set_zorder(1e6 + child.get_zorder())

        try:
            # What kind of object...
            if isinstance(child, matplotlib.patches.Patch):
                self.draw_patch(ax, child, force_trans=ax.transAxes)
            elif isinstance(child, matplotlib.text.Text):
                if (
                    child is not legend.get_children()[-1]
                    and child.get_text() != "None"
                ):
                    self.draw_text(ax, child, force_trans=ax.transAxes)
            elif isinstance(child, matplotlib.lines.Line2D):
                self.draw_line(ax, child, force_trans=ax.transAxes)
            elif isinstance(child, matplotlib.collections.Collection):
                self.draw_collection(ax, child, force_pathtrans=ax.transAxes)
            else:
                warnings.warn("Legend element %s not impemented" % child)
        except NotImplementedError:
            warnings.warn("Legend element %s not impemented" % child)