rendering strings with a ")" in an eps image

Hi folks,

I am trying to do something similar to:

from pylab import *
plot([1,2,3,4])
text(1,3,'a)')
savefig('test.eps')

I can't render the eps file because of the way that "a)" is recorded ["(a)"
will render, so its just a parsing issue]. I think, in the eps file "(a))
show" should read "(a\)) show" for the image will render.

Changing line 353 in backend_ps.py to

self._pswriter.write("(%s) show\n"%s.replace(')','\)').replace('(','\('))

would do the trick.

I'm using gentoo linux and matplotlib 0.71.

···

--

Darren

Hello Darren,

I can't render the eps file because of the way that "a)" is recorded ["(a)"
will render, so its just a parsing issue]. I think, in the eps file "(a))
show" should read "(a\)) show" for the image will render.

Thank you for spotting this. I fixed it in CVS.

John: my fix contains the fancy expression

    re.sub(r"[^ -~\n]", lambda x: r"\%03o"%ord(x.group()), s)

to quote all non-ASCII characters. Is this safe with all supported
Python versions or do I need to be more portable here?

All the best,
Jochen

···

On Wed, Jan 26, 2005 at 03:08:17PM -0500, Darren Dale wrote:
--