Re: [Matplotlib-users] Errors with PDF (TeX-string) output using Qt4Agg

2009-10-12 Thread Michael Droettboom
thon25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf',
>  10.0, 101, 'e'), (2
> 7.2216796875, 3.40625, 
> 'C:\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf',
>  10.0, 32, 'space'), (30.400
> 390625, 3.40625, 
> 'C:\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf',
>  10.0, 109, 'm'), (40.1416015625,
> 3.40625, 
> 'C:\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf',
>  10.0, 97, 'a'), (46.26953125, 3.40625, 'C
> :\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf', 
> 10.0, 116, 't'), (50.1904296875, 3.40625, 'C:\\Pytho
> n25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf', 10.0, 
> 104, 'h'), (56.5283203125, 3.40625, 'C:\\Python25\\lib
> \\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf', 10.0, 58, 
> 'colon'), (59.8974609375, 3.40625, 'C:\\Python25\\lib\\sit
> e-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf', 10.0, 32, 'space'), 
> (63.076171875, 3.40625, 'C:\\Python25\\lib\\site-pack
> ages\\matplotlib\\mpl-data\\fonts\\ttf\\STIXNonUniIta.ttf', 10.0, 57835, 
> 'uniE1EB'), (67.75616455078125, 2.046875, 'C:\\Python25\\
> lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\STIXGeneralItalic.ttf', 
> 7.0, 120378, 'u1D63A')], [], {'C:\\Python25\\lib\\si
> te-packages\\matplotlib\\mpl-data\\fonts\\ttf\\STIXGeneralItalic.ttf': 
> ('C:\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\f
> onts\\ttf\\STIXGeneralItalic.ttf', set([120378])), 
> 'C:\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf':
>   
> ('C:\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf',
>  set([32, 97, 101, 104, 109, 111, 115, 116, 58]))
> , 
> 'C:\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\STIXNonUniIta.ttf':
>  ('C:\\Python25\\lib\\site-packages\\mat
> plotlib\\mpl-data\\fonts\\ttf\\STIXNonUniIta.ttf', set([57835]))})
> (Pdb) p fonttype, global_fonttype
> (42, 42)
>
>
>
>> -Original Message-
>> From: Jouni K. Seppänen [mailto:j...@iki.fi]
>> Sent: Monday, October 12, 2009 1:18 PM
>> To: matplotlib-users@lists.sourceforge.net
>> Subject: Re: [Matplotlib-users] Errors with PDF (TeX-string) output
>> using Qt4Agg
>>
>>   writes:
>>
>>  
>>>File "C:\Python25\Lib\site-
>>>
>> packages\matplotlib\backends\backend_pdf.py", line 1378, in
>> draw_mathtext
>>  
>>>  self.file.output(self.encode_string(unichr(num), fonttype),
>>>
>> Op.show)
>>  
>>> ValueError: unichr() arg not in range(0x1) (narrow Python build)
>>>
>> Right, IPython really had mangled the traceback. That looks like the
>> mathtext parser is outputting some characters outside the Basic
>> Multilingual Plane. Could you try the following:
>>
>> python -i c:\GDAG2009\python\pyTest.py -d pdf
>>
>> Then when the error occurs, you should be at a Python prompt. Then
>> type
>> (or just copy and paste from here - be careful with the first two
>> lines,
>> since any exception will cause Python to forget the existing
>> traceback):
>>
>> from pdb import pm
>> pm()
>> p fontname, fontsize, num, symbol_name
>> p s, width, height, descent, glyphs, rects, used_characters
>> p fonttype, global_fonttype
>>
>> It might work to set pdf.fonttype to 3 in matplotlibrc, but even if it
>> helps, it would be useful to find the root of this problem.
>>
>> --
>> Jouni K. Seppänen
>> http://www.iki.fi/jks
>>
>>
>> --
>> 
>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart
>> your
>> developing skills, take BlackBerry mobile applications to market and
>> stay
>> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>> http://p.sf.net/sfu/devconference
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>  
> --
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Errors with PDF (TeX-string) output using Qt4Agg

2009-10-12 Thread PHobson
Mike,

Thanks for the reply. I found that I had (on a whim) set my mathtext.fontset to 
stixsans and then forgot about it. Returning that value to cm fixes my issues. 
In short, I'm all squared away now. Thanks!

Paul M. Hobson  


> -Original Message-
> From: Michael Droettboom [mailto:md...@stsci.edu]
> Sent: Monday, October 12, 2009 1:38 PM
> To: matplotlib-users@lists.sourceforge.net
> Subject: Re: [Matplotlib-users] Errors with PDF (TeX-string) output
> using Qt4Agg
> 
> On 10/12/2009 04:17 PM, Jouni K. Seppänen wrote:
> >   writes:
> >
> >
> >>File "C:\Python25\Lib\site-
> packages\matplotlib\backends\backend_pdf.py", line 1378, in
> draw_mathtext
> >>  self.file.output(self.encode_string(unichr(num), fonttype),
> Op.show)
> >> ValueError: unichr() arg not in range(0x1) (narrow Python
> build)
> >>
> > Right, IPython really had mangled the traceback. That looks like the
> > mathtext parser is outputting some characters outside the Basic
> > Multilingual Plane. Could you try the following:
> >
> > python -i c:\GDAG2009\python\pyTest.py -d pdf
> >
> > Then when the error occurs, you should be at a Python prompt. Then
> type
> > (or just copy and paste from here - be careful with the first two
> lines,
> > since any exception will cause Python to forget the existing
> traceback):
> >
> > from pdb import pm
> > pm()
> > p fontname, fontsize, num, symbol_name
> > p s, width, height, descent, glyphs, rects, used_characters
> > p fonttype, global_fonttype
> >
> > It might work to set pdf.fonttype to 3 in matplotlibrc, but even if
> it
> > helps, it would be useful to find the root of this problem.
> >
> >
> What is your mathtext.fontset setting?  If it's stixsans, then it is
> possible that mathtext would produce codepoints outside of the BMP
> (this
> is due to the way the STIX fonts are encoded).  Unfortunately, the
> standard Python builds for Windows don't support characters in this
> range.
> 
> There might actually be a work around possible in the PDF backend --
> but
> it will have to involve encoding Unicode characters without using
> Python
> unicode objects.  I'm looking into a patch now.
> 
> Cheers,
> Mike
> 
> --
> 
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart
> your
> developing skills, take BlackBerry mobile applications to market and
> stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Errors with PDF (TeX-string) output using Qt4Agg

2009-10-12 Thread PHobson
lib\\site-pack
ages\\matplotlib\\mpl-data\\fonts\\ttf\\STIXNonUniIta.ttf', 10.0, 57835, 
'uniE1EB'), (67.75616455078125, 2.046875, 'C:\\Python25\\
lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\STIXGeneralItalic.ttf', 
7.0, 120378, 'u1D63A')], [], {'C:\\Python25\\lib\\si
te-packages\\matplotlib\\mpl-data\\fonts\\ttf\\STIXGeneralItalic.ttf': 
('C:\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\f
onts\\ttf\\STIXGeneralItalic.ttf', set([120378])), 
'C:\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf':
 
('C:\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf',
 set([32, 97, 101, 104, 109, 111, 115, 116, 58]))
, 
'C:\\Python25\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\STIXNonUniIta.ttf':
 ('C:\\Python25\\lib\\site-packages\\mat
plotlib\\mpl-data\\fonts\\ttf\\STIXNonUniIta.ttf', set([57835]))})
(Pdb) p fonttype, global_fonttype
(42, 42)


> -Original Message-
> From: Jouni K. Seppänen [mailto:j...@iki.fi]
> Sent: Monday, October 12, 2009 1:18 PM
> To: matplotlib-users@lists.sourceforge.net
> Subject: Re: [Matplotlib-users] Errors with PDF (TeX-string) output
> using Qt4Agg
> 
>  writes:
> 
> >   File "C:\Python25\Lib\site-
> packages\matplotlib\backends\backend_pdf.py", line 1378, in
> draw_mathtext
> > self.file.output(self.encode_string(unichr(num), fonttype),
> Op.show)
> > ValueError: unichr() arg not in range(0x1) (narrow Python build)
> 
> Right, IPython really had mangled the traceback. That looks like the
> mathtext parser is outputting some characters outside the Basic
> Multilingual Plane. Could you try the following:
> 
> python -i c:\GDAG2009\python\pyTest.py -d pdf
> 
> Then when the error occurs, you should be at a Python prompt. Then
> type
> (or just copy and paste from here - be careful with the first two
> lines,
> since any exception will cause Python to forget the existing
> traceback):
> 
> from pdb import pm
> pm()
> p fontname, fontsize, num, symbol_name
> p s, width, height, descent, glyphs, rects, used_characters
> p fonttype, global_fonttype
> 
> It might work to set pdf.fonttype to 3 in matplotlibrc, but even if it
> helps, it would be useful to find the root of this problem.
> 
> --
> Jouni K. Seppänen
> http://www.iki.fi/jks
> 
> 
> --
> 
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart
> your
> developing skills, take BlackBerry mobile applications to market and
> stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Errors with PDF (TeX-string) output using Qt4Agg

2009-10-12 Thread Michael Droettboom
On 10/12/2009 04:17 PM, Jouni K. Seppänen wrote:
>   writes:
>
>
>>File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_pdf.py", 
>> line 1378, in draw_mathtext
>>  self.file.output(self.encode_string(unichr(num), fonttype), Op.show)
>> ValueError: unichr() arg not in range(0x1) (narrow Python build)
>>  
> Right, IPython really had mangled the traceback. That looks like the
> mathtext parser is outputting some characters outside the Basic
> Multilingual Plane. Could you try the following:
>
> python -i c:\GDAG2009\python\pyTest.py -d pdf
>
> Then when the error occurs, you should be at a Python prompt. Then type
> (or just copy and paste from here - be careful with the first two lines,
> since any exception will cause Python to forget the existing traceback):
>
> from pdb import pm
> pm()
> p fontname, fontsize, num, symbol_name
> p s, width, height, descent, glyphs, rects, used_characters
> p fonttype, global_fonttype
>
> It might work to set pdf.fonttype to 3 in matplotlibrc, but even if it
> helps, it would be useful to find the root of this problem.
>
>
What is your mathtext.fontset setting?  If it's stixsans, then it is 
possible that mathtext would produce codepoints outside of the BMP (this 
is due to the way the STIX fonts are encoded).  Unfortunately, the 
standard Python builds for Windows don't support characters in this range.

There might actually be a work around possible in the PDF backend -- but 
it will have to involve encoding Unicode characters without using Python 
unicode objects.  I'm looking into a patch now.

Cheers,
Mike

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Errors with PDF (TeX-string) output using Qt4Agg

2009-10-12 Thread Jouni K . Seppänen
 writes:

>   File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_pdf.py", 
> line 1378, in draw_mathtext
> self.file.output(self.encode_string(unichr(num), fonttype), Op.show)
> ValueError: unichr() arg not in range(0x1) (narrow Python build)

Right, IPython really had mangled the traceback. That looks like the
mathtext parser is outputting some characters outside the Basic
Multilingual Plane. Could you try the following:

python -i c:\GDAG2009\python\pyTest.py -d pdf

Then when the error occurs, you should be at a Python prompt. Then type
(or just copy and paste from here - be careful with the first two lines,
since any exception will cause Python to forget the existing traceback):

from pdb import pm
pm()
p fontname, fontsize, num, symbol_name
p s, width, height, descent, glyphs, rects, used_characters
p fonttype, global_fonttype

It might work to set pdf.fonttype to 3 in matplotlibrc, but even if it
helps, it would be useful to find the root of this problem.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Errors with PDF (TeX-string) output using Qt4Agg

2009-10-12 Thread PHobson
Sheesh it's been a weird day. I failed to reply to the whole list. 

Jouni, sorry about the duplciate message...




>  writes:
> > |C:\Documents and Settings\phobson>ipython26 -pylab
>
> From: Jouni K. Seppänen [mailto:j...@iki.fi] Could you try this in 
> plain Python? I'm asking because you seem to be getting an IPython 
> warning about a possibly corrupted traceback:
> 
> > ERROR: An unexpected error occurred while tokenizing input The 
> > following traceback may be corrupted or invalid The error message 
> > is: ('EOF in multi-line statement', (550, 0))
> 
> I suggest you write your commands in a script and run it with
> 
> python script.py --verbose-debug

Jouni: Thanks for the prompt reply. I did just that. Calling the script both 
ways (w/ and w/o the PDF backend) fails with a lot of out. This time I've 
included the verbose output as an attached text file. I apologize of that's a 
mailing list faux pas. Here's the code for the script, pyTest.py:

import pylab as pl
x = pl.arange(6)
y = x + 5
pl.plot(x,y,'ko', zorder=10)
pl.xlabel('X-label, no TeX')
pl.ylabel('Y-label. no math')
pl.savefig('no_math.png')
pl.savefig('no_math.pdf')

pl.xlabel(r'some math: $\tau_{y}$')
pl.savefig('some_math.png')
pl.savefig('some_math.pdf')
# EOF

no_math.* and some_math.png are created just fine. The error occurred trying to 
create some_math.pdf.

I'm really at a loss b/c I could swear I created fairly complex figures with 
output to PDF about a week ago and don't recall changing my Python or MPL 
installation.

> so that we can get a better picture of where it is going wrong.
> 
> Also, does it matter that you are using Qt4Agg? You can test this by 
> trying

Both seemed to provide the same error message, so I've only included the 
verbose output from C:\Python25>python c:\GDAG2009\python\pyTest.py -d pdf 
--verbose-debug

For grins and giggles, I went to my matplotlibrc file and commented out the 
lines telling MPL to use Droid fonts (even though they never gave me a problem 
before). That didn't change anything.

Thanks again,
-paul
C:\Python25>python c:\GDAG2009\python\pyTest.py -d pdf --verbose-debug
$HOME=C:\Documents and Settings\phobson
CONFIGDIR=C:\Documents and Settings\phobson\.matplotlib
matplotlib data path C:\Python25\lib\site-packages\matplotlib\mpl-data
loaded rc file C:\Documents and Settings\phobson\.matplotlib\matplotlibrc
matplotlib version 0.99.1
verbose.level debug
interactive is False
units is False
platform is win32
loaded modules: ['numpy.lib._iotools', 'xml.sax.urlparse', 'distutils', 
'matplotlib.errno', 'pylab', 'subprocess', 'gc', 'matplotl
ib.tempfile', 'distutils.sysconfig', 'ctypes._endian', 'encodings.encodings', 
'matplotlib.colors', 'msvcrt', 'numpy.testing.sys',
'numpy.core.info', 'xml', 'numpy.fft.types', 'numpy.ma.operator', 
'numpy.ma.cPickle', 'struct', 'numpy.random.info', 'tempfile', '
xml.sax.urllib', 'numpy.linalg', 'matplotlib.threading', 
'numpy.testing.operator', 'imp', 'numpy.testing', 'collections', 'numpy.c
ore.umath', '_struct', 'distutils.types', 'numpy.lib.numpy', 
'numpy.core.scalarmath', 'matplotlib.matplotlib', 'string', 'matplotl
ib.subprocess', 'numpy.testing.os', 'matplotlib.locale', 
'numpy.lib.arraysetops', 'numpy.testing.unittest', 'numpy.lib.math', 'mat
plotlib.__future__', 'numpy.testing.re', 'itertools', 'numpy.version', 
'numpy.lib.re', 'distutils.re', 'ctypes.os', 'numpy.core.os
', 'numpy.lib.type_check', 'numpy.lib.__builtin__', 'signal', 
'numpy.lib.types', 'numpy.lib._datasource', 'random', 'threading', '
token', 'numpy.fft.fftpack_lite', 'matplotlib.cbook', 'ctypes.ctypes', 
'xml.sax.xmlreader', 'numpy.__builtin__', 'dis', 'distutils
.version', 'cStringIO', 'numpy.ma.core', 'numpy.numpy', 'matplotlib.StringIO', 
'locale', 'numpy.add_newdocs', 'numpy.lib.getlimits
', 'xml.sax.saxutils', 'matplotlib.numpy', 'numpy.lib.sys', 'encodings', 
'numpy.ma.itertools', 'numpy.lib.io', 'numpy.ma.extras',
'numpy.testing.decorators', 'matplotlib.warnings', 'matplotlib.string', 
'_subprocess', 'urllib', 'matplotlib.sys', 're', 'numpy.li
b._compiled_base', 'ntpath', 'new', 'numpy.random.mtrand', 'math', 
'numpy.fft.helper', 'numpy.ma.warnings', 'inspect', 'numpy.ma.i
nspect', 'UserDict', 'numpy.lib.function_base', 'distutils.os', 'matplotlib', 
'numpy.fft.numpy', 'numpy.lib.ufunclike', 'numpy.lib
.info', 'numpy.core.numerictypes', 'ctypes', 'numpy.lib.warnings', 
'ctypes.struct', 'codecs', 'numpy.core._sort', 'numpy.os', '_lo
cale', 'matplotlib.sre_constants', 'matplotlib.os', 'thread', 'StringIO', 
'numpy.core.memmap', 'traceback', 'weakref', 'numpy.core
._internal', 'numpy.fft.fftpack', 'opcode', 'numpy.linalg.lapack_lite', 
'distutils.sys', 'os', 'numpy.lib.itertools', '__future__'
, 'matplotlib.copy', 'xml.sax.types', 'matplotlib.traceback', '_sre', 
'unittest', 'numpy.core.sys', 'numpy.random', 'numpy.linalg.
numpy', '__builtin__', 'numpy.lib.twodim_base', 'matplotlib.re', 
'numpy.core.cPickle', 'operator', 'numpy.core.arrayprint', 'distu
tils.string', 'num

Re: [Matplotlib-users] Errors with PDF (TeX-string) output using Qt4Agg

2009-10-12 Thread Jouni K . Seppänen
 writes:

> |C:\Documents and Settings\phobson>ipython26 -pylab

Could you try this in plain Python? I'm asking because you seem to be
getting an IPython warning about a possibly corrupted traceback:

> ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (550, 0))

I suggest you write your commands in a script and run it with 

python script.py --verbose-debug

so that we can get a better picture of where it is going wrong.

Also, does it matter that you are using Qt4Agg? You can test this by
trying

python script.py -d pdf --verbose-debug

If that works, then the problem could be related to Qt4Agg specifically,
but if it fails, it is somewhere else.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Errors with PDF (TeX-string) output using Qt4Agg

2009-10-12 Thread PHobson
Group,

This error occurs for me with Matplotlib 0.99.1, Python 2.5.4 and 2.6.2, while 
using the Qt4Agg backend on Windows XP.

Basically, savefig('aweomse_plot.pdf') barfs if I have some math text in there. 

For example:
--
|C:\Documents and Settings\phobson>ipython26 -pylab
|Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)]
|Type "copyright", "credits" or "license" for more information.
|
|IPython 0.10 -- An enhanced Interactive Python.
|? -> Introduction and overview of IPython's features.
|%quickref -> Quick reference.
|help  -> Python's own help system.
|object?   -> Details about 'object'. ?object also works, ?? prints more
|
|  Welcome to pylab, a matplotlib-based Python environment.
|  For more information, type 'help(pylab)'.In [1]: x = arange(10)
|
|In [2]: y = 0.5*x**2
|
|In [3]: plot(x,y,'ko')
|Out[3]: []
|
|In [4]: savefig('test.png')
|
|In [5]: savefig('test.pdf')
|
|In [6]: xlabel('rSome math: $X$')
|Out[6]: 
|
|In [7]: savefig('test.pdf')
--
Spits out a nasty error at Input Line 7. I've include it below my sig for those 
who might want to look at it.

I don't know much about back ends, but I feel like I've neglected to install 
something since the last line of the TraceBack includes "ValueError: unichr() 
arg not in range(0x1) (narrow Python build)".

I have an update-version of MikTeX on this machine. Any thoughts?

Many thanks,

Paul M. Hobson  
Senior Staff Engineer
-- 
Geosyntec Consultants 
55 SW Yamhill St, Ste 200
Portland, OR 97204
Phone: (503) 222-9518
Web:   www.geosyntec.com

Erros message:

In [7]: savefig('test.pdf')
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (550, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (550, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (550, 0))

---
ValueErrorTraceback (most recent call last)

C:\Documents and Settings\phobson\ in ()

C:\Python26\lib\site-packages\matplotlib\pyplot.pyc in savefig(*args, **kwargs)
354 def savefig(*args, **kwargs):
355 fig = gcf()
--> 356 return fig.savefig(*args, **kwargs)
357 if Figure.savefig.__doc__ is not None:
358 savefig.__doc__ = dedent(Figure.savefig.__doc__)

C:\Python26\lib\site-packages\matplotlib\figure.pyc in savefig(self, *args, 
**kwargs)
   1030 patch.set_alpha(0.0)
   1031
-> 1032 self.canvas.print_figure(*args, **kwargs)
   1033
   1034 if transparent:

C:\Python26\lib\site-packages\matplotlib\backends\backend_qt4agg.pyc in 
print_figure(self, *args, **kwargs)
141 self.update(l, self.renderer.height-t, w, h)
142
143 def print_figure(self, *args, **kwargs):
--> 144 FigureCanvasAgg.print_figure(self, *args, **kwargs)
145 self.draw()

C:\Python26\lib\site-packages\matplotlib\backend_bases.pyc in 
print_figure(self, filename, dpi, facecolor, edgecolor, orientation
 format, **kwargs)
   1474 orientation=orientation,
   1475 bbox_inches_restore=_bbox_inches_restore,
-> 1476 **kwargs)
   1477 finally:
   1478 if bbox_inches and restore_bbox:

C:\Python26\lib\site-packages\matplotlib\backend_bases.pyc in print_pdf(self, 
*args, **kwargs)
   1332 from backends.backend_pdf import FigureCanvasPdf # lazy import
   1333 pdf = self.switch_backends(FigureCanvasPdf)
-> 1334 return pdf.print_pdf(*args, **kwargs)
   1335
   1336 def print_png(self, *args, **kwargs):

C:\Python26\lib\site-packages\matplotlib\backends\backend_pdf.pyc in 
print_pdf(self, filename, **kwargs)
   2023 width, height, image_dpi, RendererPdf(file, image_dpi),
   2024 bbox_inches_restore=_bbox_inches_restore)
-> 2025 self.figure.draw(renderer)
   2026 renderer.finalize()
   2027 if isinstance(filename, PdfPages): # finish off this page

C:\Python26\lib\site-packages\matplotlib\artist.pyc in draw_wrapper(artist, 
renderer, *kl)
 44 def draw_wrapper(artist, renderer, *kl):
 45 before(artist, renderer)
---> 46 draw(artist, renderer, *kl)
 47 after(artist, renderer)
 48

C:\Python26\lib\site-packages\matplotlib\figure.pyc in draw(self, renderer)
771
772 # render the axes

--> 773 for a in self.axes: a.draw(renderer)
774
775 # render the figure text