Matplotlib: Qt4Agg toolbar, annoying bug

I use Qt4Agg (PyQt4) as a backend for rendering graphs in matplotlib. This is a very useful toolbar with a very useful button "Edit Curve Lines and Axis Parameters". However, whenever I click on it, it gives an error. (I know this is useful since it works for histograms, but not for line graphs: P).

The reasons and tracing are clearly visible in the figure below.

enter image description here

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

This is the simplest script that gives the same error (the graph will differ from the previous one) -

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

(I configured the backend via the /etc/matplotlibrc configuration file)

Please help me fix this problem.

+1
source share
1 answer

It really looks like a bug in the Qt4 form editor for matplotlib.

The error is within the section of the FormWidget.setup() method in matplotlib/backends/qt4_editor/formwidget.py . In matplotlib 1.1.0 on Windows (where I could not 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 above

  selindex = list(value).pop(0) 

Ultimately, none of the versions are correct.

The problem with version 1.1.0 method is that it does not process tuples (tuples are immutable and have no pop ) method, and the problem with version 1.1.1rc code is that the first value element must be removed, but it is only removed from the temporary list generated by list(value) .

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

+1
source

Source: https://habr.com/ru/post/1232636/


All Articles