Subject: matplotlib broken

From: Ricardo Wurmus <[email-masked]>
Date: Wed, 1 Jul 2015 16:50:26 +0200

I'm afraid I cannot reproduce this.  This doesn't mean things just work
for me.  It rather means that I'm getting a different error:

$ GI_TYPELIB_PATH=$HOME/.guix-profile/lib/girepository-1.0/ PYTHONPATH=$HOME/.guix-profile/lib/python2.7/site-packages/ python
Python 2.7.6 (default, Jun 16 2015, 17:15:41) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import matplotlib.pyplot as plt

(process:1384): Gtk-WARNING **: Locale not supported by C library.
	Using the fallback 'C' locale.
>>> t = np.r_[0:5]
>>> plt.plot(t, t)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/gnu/store/3qmjvhsyj5ccwx0d3lcmsirb9a78473v-python2-matplotlib-1.4.2/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 3092, in plot
    ax = gca()
  File "/gnu/store/3qmjvhsyj5ccwx0d3lcmsirb9a78473v-python2-matplotlib-1.4.2/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 828, in gca
    ax =  gcf().gca(**kwargs)
  File "/gnu/store/3qmjvhsyj5ccwx0d3lcmsirb9a78473v-python2-matplotlib-1.4.2/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 462, in gcf
    return figure()
  File "/gnu/store/3qmjvhsyj5ccwx0d3lcmsirb9a78473v-python2-matplotlib-1.4.2/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 435, in figure
    **kwargs)
  File "/gnu/store/3qmjvhsyj5ccwx0d3lcmsirb9a78473v-python2-matplotlib-1.4.2/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtk3agg.py", line 110, in new_figure_manager
    return new_figure_manager_given_figure(num, thisFig)
  File "/gnu/store/3qmjvhsyj5ccwx0d3lcmsirb9a78473v-python2-matplotlib-1.4.2/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtk3agg.py", line 117, in new_figure_manager_given_figure
    canvas = FigureCanvasGTK3Agg(figure)
  File "/gnu/store/3qmjvhsyj5ccwx0d3lcmsirb9a78473v-python2-matplotlib-1.4.2/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtk3agg.py", line 25, in __init__
    backend_gtk3.FigureCanvasGTK3.__init__(self, figure)
  File "/gnu/store/3qmjvhsyj5ccwx0d3lcmsirb9a78473v-python2-matplotlib-1.4.2/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtk3.py", line 210, in __init__
    self._idle_event_id = GLib.idle_add(self.idle_event)
  File "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/gi/types.py", line 44, in function
    return info.invoke(*args)
TypeError: Error invoking GLib.idle_add: Unexpected value for argument 'function'

I don't know what this means.

On the other hand I get along without any errors if I set the backend to
'Agg' before importing pyplot:

>>> import numpy as np
>>> import matplotlib
>>> matplotlib.use('Agg')
>>> import matplotlib.pyplot as plt
>>> t = np.r_[0:5]
>>> plt.plot(t, t)
[<matplotlib.lines.Line2D object at 0x1e2a950>]
>>> ^C

I understand that this could then be used to write the plot to a file.
Do we actually need to use the Gtk+ backend by default?

~~ Ricardo