I connect remotely using:
ssh -X
then I have a code that has:
#! /usr/bin/env python
import matplotlib
matplotlib.use('Agg')
...
fig = plt.figure(figsize=(8.5,9.))
...
fig.savefig(plotfile)
The code works until saving the plot. Then I get the following:
Traceback (most recent call last):
File "./lf_compared.py", line 171, in <module>
fig.savefig(plotfile)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/figure.py", line 1470, in savefig
self.canvas.print_figure(*args, **kwargs)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backend_bases.py", line 2194, in print_figure
**kwargs)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backends/backend_ps.py", line 989, in print_ps
return self._print_ps(outfile, 'ps', *args, **kwargs)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backends/backend_ps.py", line 1020, in _print_ps
**kwargs)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backends/backend_ps.py", line 1110, in _print_figure
self.figure.draw(renderer)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/figure.py", line 1079, in draw
func(*args)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/axes/_base.py", line 2092, in draw
a.draw(renderer)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/legend.py", line 462, in draw
self._legend_box.draw(renderer)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/offsetbox.py", line 273, in draw
c.draw(renderer)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/offsetbox.py", line 273, in draw
c.draw(renderer)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/offsetbox.py", line 273, in draw
c.draw(renderer)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/offsetbox.py", line 273, in draw
c.draw(renderer)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/offsetbox.py", line 814, in draw
self._text.draw(renderer)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/text.py", line 554, in draw
gc.set_foreground(self.get_color())
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backend_bases.py", line 991, in set_foreground
self._rgb = colors.colorConverter.to_rgba(fg)
File "/cosma/local/matplotlib/1.4.2/lib/python/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/colors.py", line 376, in to_rgba
'to_rgba: Invalid rgba arg "%s"\n%s' % (str(arg), exc))
ValueError: to_rgba: Invalid rgba arg "g--"
to_rgb: Invalid rgb arg "g--"
could not convert string to float: g--
I think the problem has to do with saving remotely the plots, since I've used the program before and it ran fine. By searching I found the use of 'Agg' to be the solution in most cases, but it doesn't seem to work for me. Any ideas? Thanks