Dear All,
I am running Debian testing on my box and I use pylab as installed
from the standard repositories.
Unfortunately, it seems that there is something broken either with
pylab or Python (I have been upgrading the system these days) since I
am now unable to create .pdf files:
For instance, consider the following simple script:
#! /usr/bin/env python
import scipy as s
import numpy as n
import pylab as p
a=s.linspace(0.,40.,20)
b=s.linspace(-20.,90.,20)
fig = p.figure()
axes = fig.gca()
axes.plot(a,b, "bo",label="test plot")
p.xlabel('Time')
p.ylabel('Number of clusters')
p.title("Evolution Number of clusters")
p.grid(True)
cluster_name="test.pdf"
axes.legend()
p.savefig(cluster_name)
p.clf()
The output generated by the script is:
Traceback (most recent call last):
File "<stdin>", line 25, in <module>
File "/usr/lib/python2.5/site-packages/matplotlib/pylab.py", line
796, in savefig
return fig.savefig(*args, **kwargs)
File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line
759, in savefig
self.canvas.print_figure(*args, **kwargs)
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py",
line 114, in print_figure
orientation, **kwargs)
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 497, in print_figure
printfunc(filename, dpi, facecolor, edgecolor, orientation, **kwargs)
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 1395, in print_figure
file.close()
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 401, in close
self.writeFonts()
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 456, in writeFonts
fontdictObject = self.embedTTF(filename)
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 508, in embedTTF
widths = [ get_char_width(charcode) for charcode in
range(firstchar, lastchar+1) ]
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 505, in get_char_width
unicode = cp1252.decoding_map[charcode] or 0
AttributeError: 'module' object has no attribute 'decoding_map'
and no pdf file is produced. However, if I try saving it as a .png
file (by setting cluster_name="test.png"), then everything works
fine.
This is very annoying and I wonder if anyone else is having the same
problem and can put forward a suggestion to help.
Many thanks
Lorenzo