# Buggy code
def figure_edit(axes, parent=None):
    """Edit matplotlib figure options"""
    sep = (None, None)  # separator

    has_curve = len(axes.get_lines()) > 0

    # Get / General
    xmin, xmax = axes.get_xlim()
    ymin, ymax = axes.get_ylim()
    general = [
        ("Title", axes.get_title()),
        sep,
        (None, "<b>X-Axis</b>"),
        ("Min", xmin),
        ("Max", xmax),
        ("Label", axes.get_xlabel()),
        ("Scale", [axes.get_xscale(), "linear", "log"]),
        sep,
        (None, "<b>Y-Axis</b>"),
        ("Min", ymin),
        ("Max", ymax),
        ("Label", axes.get_ylabel()),
        ("Scale", [axes.get_yscale(), "linear", "log"]),
        sep,
        ("(Re-)Generate automatic legend", False),
    ]

    if has_curve:
        # Get / Curves
        linedict = {}
        for line in axes.get_lines():
            label = line.get_label()
            if label == "_nolegend_":
                continue
            linedict[label] = line
        curves = []
        linestyles = list(six.iteritems(LINESTYLES))
        markers = list(six.iteritems(MARKERS))
        curvelabels = sorted(linedict.keys())
        for label in curvelabels:
            line = linedict[label]
            curvedata = [
                ("Label", label),
                sep,
                (None, "<b>Line</b>"),
                ("Style", [line.get_linestyle()] + linestyles),
                ("Width", line.get_linewidth()),
                ("Color", line.get_color()),
                sep,
                (None, "<b>Marker</b>"),
                ("Style", [line.get_marker()] + markers),
                ("Size", line.get_markersize()),
                ("Facecolor", line.get_markerfacecolor()),
                ("Edgecolor", line.get_markeredgecolor()),
            ]
            curves.append([curvedata, label, ""])

    datalist = [(general, "Axes", "")]
    if has_curve:
        datalist.append((curves, "Curves", ""))

    def apply_callback(data):
        """This function will be called to apply changes"""
        if has_curve:
            general, curves = data
        else:
            (general,) = data

        # Set / General
        (
            title,
            xmin,
            xmax,
            xlabel,
            xscale,
            ymin,
            ymax,
            ylabel,
            yscale,
            generate_legend,
        ) = general
        axes.set_xscale(xscale)
        axes.set_yscale(yscale)
        axes.set_title(title)
        axes.set_xlim(xmin, xmax)
        axes.set_xlabel(xlabel)
        axes.set_ylim(ymin, ymax)
        axes.set_ylabel(ylabel)

        if has_curve:
            # Set / Curves
            for index, curve in enumerate(curves):
                line = linedict[curvelabels[index]]
                (
                    label,
                    linestyle,
                    linewidth,
                    color,
                    marker,
                    markersize,
                    markerfacecolor,
                    markeredgecolor,
                ) = curve
                line.set_label(label)
                line.set_linestyle(linestyle)
                line.set_linewidth(linewidth)
                line.set_color(color)
                if marker is not "none":
                    line.set_marker(marker)
                    line.set_markersize(markersize)
                    line.set_markerfacecolor(markerfacecolor)
                    line.set_markeredgecolor(markeredgecolor)

        # re-generate legend, if checkbox is checked
        if generate_legend:
            if axes.legend_ is not None:
                old_legend = axes.get_legend()
                new_legend = axes.legend(ncol=old_legend._ncol)
                new_legend.draggable(old_legend._draggable is not None)
            else:
                new_legend = axes.legend()
                new_legend.draggable(True)

        # Redraw
        figure = axes.get_figure()
        figure.canvas.draw()

    data = formlayout.fedit(
        datalist,
        title="Figure options",
        parent=parent,
        icon=get_icon("qt4_editor_options.svg"),
        apply=apply_callback,
    )
    if data is not None:
        apply_callback(data)


# Traceback (IndexError)
$ ipython --pylab
Python 3.4.3 (default, Mar 25 2015, 17:13:50)
Type "copyright", "credits" or "license" for more information.

IPython 3.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
romUsing matplotlib backend: Qt5Agg
Using matplotlib backend: Qt5Agg
se
In [1]: from seaborn import *; tsplot([1, 2])
Out[1]: <matplotlib.axes._subplots.AxesSubplot at 0x7f0262043d30>
# <------ click on green tick
In [2]: Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/matplotlib/backends/backend_qt5.py", line 653, in edit_parameters
figureoptions.figure_edit(axes, self)
File "/usr/lib/python3.4/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 146, in figure_edit
apply=apply_callback)
File "/usr/lib/python3.4/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 510, in fedit
dialog = FormDialog(data, title, comment, icon, parent, apply)
File "/usr/lib/python3.4/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 416, in __init__
parent=self)
File "/usr/lib/python3.4/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 389, in __init__
if len(data[0]) == 3:
IndexError: list index out of range

If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True

# Fixed code
def figure_edit(axes, parent=None):
    """Edit matplotlib figure options"""
    sep = (None, None)  # separator

    has_curve = len(axes.get_lines()) > 0

    # Get / General
    xmin, xmax = axes.get_xlim()
    ymin, ymax = axes.get_ylim()
    general = [
        ("Title", axes.get_title()),
        sep,
        (None, "<b>X-Axis</b>"),
        ("Min", xmin),
        ("Max", xmax),
        ("Label", axes.get_xlabel()),
        ("Scale", [axes.get_xscale(), "linear", "log"]),
        sep,
        (None, "<b>Y-Axis</b>"),
        ("Min", ymin),
        ("Max", ymax),
        ("Label", axes.get_ylabel()),
        ("Scale", [axes.get_yscale(), "linear", "log"]),
        sep,
        ("(Re-)Generate automatic legend", False),
    ]

    if has_curve:
        # Get / Curves
        linedict = {}
        for line in axes.get_lines():
            label = line.get_label()
            if label == "_nolegend_":
                continue
            linedict[label] = line
        curves = []
        linestyles = list(six.iteritems(LINESTYLES))
        markers = list(six.iteritems(MARKERS))
        curvelabels = sorted(linedict.keys())
        for label in curvelabels:
            line = linedict[label]
            curvedata = [
                ("Label", label),
                sep,
                (None, "<b>Line</b>"),
                ("Style", [line.get_linestyle()] + linestyles),
                ("Width", line.get_linewidth()),
                ("Color", line.get_color()),
                sep,
                (None, "<b>Marker</b>"),
                ("Style", [line.get_marker()] + markers),
                ("Size", line.get_markersize()),
                ("Facecolor", line.get_markerfacecolor()),
                ("Edgecolor", line.get_markeredgecolor()),
            ]
            curves.append([curvedata, label, ""])
    # make sure that there is at least one displayed curve
    has_curve = bool(curves)

    datalist = [(general, "Axes", "")]
    if has_curve:
        datalist.append((curves, "Curves", ""))

    def apply_callback(data):
        """This function will be called to apply changes"""
        if has_curve:
            general, curves = data
        else:
            (general,) = data

        # Set / General
        (
            title,
            xmin,
            xmax,
            xlabel,
            xscale,
            ymin,
            ymax,
            ylabel,
            yscale,
            generate_legend,
        ) = general
        axes.set_xscale(xscale)
        axes.set_yscale(yscale)
        axes.set_title(title)
        axes.set_xlim(xmin, xmax)
        axes.set_xlabel(xlabel)
        axes.set_ylim(ymin, ymax)
        axes.set_ylabel(ylabel)

        if has_curve:
            # Set / Curves
            for index, curve in enumerate(curves):
                line = linedict[curvelabels[index]]
                (
                    label,
                    linestyle,
                    linewidth,
                    color,
                    marker,
                    markersize,
                    markerfacecolor,
                    markeredgecolor,
                ) = curve
                line.set_label(label)
                line.set_linestyle(linestyle)
                line.set_linewidth(linewidth)
                line.set_color(color)
                if marker is not "none":
                    line.set_marker(marker)
                    line.set_markersize(markersize)
                    line.set_markerfacecolor(markerfacecolor)
                    line.set_markeredgecolor(markeredgecolor)

        # re-generate legend, if checkbox is checked
        if generate_legend:
            if axes.legend_ is not None:
                old_legend = axes.get_legend()
                new_legend = axes.legend(ncol=old_legend._ncol)
                new_legend.draggable(old_legend._draggable is not None)
            else:
                new_legend = axes.legend()
                new_legend.draggable(True)

        # Redraw
        figure = axes.get_figure()
        figure.canvas.draw()

    data = formlayout.fedit(
        datalist,
        title="Figure options",
        parent=parent,
        icon=get_icon("qt4_editor_options.svg"),
        apply=apply_callback,
    )
    if data is not None:
        apply_callback(data)