1

I am using the Qt4Agg (PyQt4) as the backend for rendering plots in matplotlib. This has a very useful toolbar with a very useful button 'Edit curve lines and axes parameters'. However, whenever I press it, it gives an error. (I know that it is useful as it works for bar graphs, but not for line plots :P).

The cause and traceback can be seen clearly in the picture below.

enter image description here

I thought this might be a bug the current version of matplotlib so I tried this on the latest version of the same but it still gives the same error.

This is simplest script which gives the same error (plot will be different from above) -

import matplotlib.pyplot as plt
plt.plot(range(10))
plt.show()

(I have configured the backend through the configuration file /etc/matplotlibrc)

Please help me fix this problem.

Pushpak Dagade
  • 6,280
  • 7
  • 28
  • 41

1 Answers1

1

This does indeed seem to be a bug in the Qt4 form editor for matplotlib.

The error appears to be within a section of the FormWidget.setup() method, in matplotlib/backends/qt4_editor/formwidget.py. In matplotlib 1.1.0 on Windows (where I couldn't reproduce the problem), it contains the following:

        elif isinstance(value, (list, tuple)):
            selindex = value.pop(0)
            field = QComboBox(self)
            if isinstance(value[0], (list, tuple)):
                keys = [ key for key, _val in value ]
                value = [ val for _key, val in value ]
            else:
                keys = value
            field.addItems(value)

matplotlib v1.1.1rc on Kubuntu Precise (where I could reproduce the problem) replaces the second line of the above with

            selindex = list(value).pop(0)

Ultimately, neither version is correct.

The problem with the version 1.1.0 method is that it doesn't handle tuples (tuples are immutable and don't have a pop) method, and the problem with the version 1.1.1rc code is that the first element of value is supposed to be removed, but it only gets removed from the temporary list that list(value) creates.

This bug is fixed in version 1.1.1. I've just downloaded and installed this version and can no longer reproduce the problem.

Luke Woodward
  • 63,336
  • 16
  • 89
  • 104
  • Thanks Luke :). I thought I had the latest version as I tested it on a ubuntu 12.04 machine, but it wasn't. It was 1.1.1rc. So I just installed the latest version from github and it now works wonderfully! Thank you. – Pushpak Dagade Sep 16 '12 at 15:44