|
From: Nikolaus R. <Nik...@ra...> - 2012-10-10 13:39:52
|
Benjamin Root <ben...@pu...> writes:
>> >>> For some reason, my matplotlib isn't able to print percent signs ('%')
>> >>> properly:
>> >>>
>> >>> [1] inspiron:~/tmp# cat mplbug.py
>> >>>
>> >>> import matplotlib
>> >>> import matplotlib.pyplot as plt
>> >>> import numpy as np
>> >>>
>> >>> print matplotlib.__version__
>> >>> plt.plot(np.arange(10), np.arange(10)**2)
>> >>> plt.xlabel('Percent [%]')
>> >>> plt.savefig('mplbug.pdf')
>> >>>
>> >>> [0] inspiron:~/tmp# python mplbug.py
>> >>> 1.1.1rc2
>> >>>
>> >>> I have attached the resulting PDF. For some reason, the slash in the
>> >>> percent sign becomes a triangle that partially covers the upper left
>> >>> circle.
>> >>>
>> >>> Known bug? Any workarounds that don't require upgrading (I'd like to
>> >>> stick with the Debian package)?
>> >>
>> >> I'm using the AGG backend and saving to a png file without any
>> >> problems, but I'm using the current git master branch. I'll try to see
>> >> if I can recreate on 1.1.1rc2. Watch this space.
>> >
>> > No dice. I still can't recreate your problem on OS X 10.7.4 with
>> > matplotlib version 1.1.1-rc2.
>> >
>> > What are your font/tex specifications in the matplotlib.rcParams
>> dictionary?
>>
>> For me the problem occurs with PDF files, not PNG files. Or was that
>> just a typo?
>>
>> Font specifications are all default.
>>
>> # python -c 'import matplotlib; import pprint;
>> # pprint.pprint(matplotlib.rcParams)' | egrep 'tex'
>> 'legend.handletextpad': 0.8,
>> 'mathtext.bf': 'serif:bold',
>> 'mathtext.cal': 'cursive',
>> 'mathtext.default': 'it',
>> 'mathtext.fallback_to_cm': True,
>> 'mathtext.fontset': 'cm',
>> 'mathtext.it': 'serif:italic',
>> 'mathtext.rm': 'serif',
>> 'mathtext.sf': 'sans\\-serif',
>> 'mathtext.tt': 'monospace',
>> 'text.antialiased': True,
>> 'text.color': 'k',
>> 'text.dvipnghack': None,
>> 'text.hinting': True,
>> 'text.latex.preamble': [''],
>> 'text.latex.preview': False,
>> 'text.latex.unicode': False,
>> 'text.usetex': False,
>>
> I think I know why this is happening. Iirc, we recently took on a patch to
> allow string formatting for labels. For most cases, it shouldn't effect
> anybody, but if there is a lonely percent sign, I would imagine it could
> cause issues. As a test, try a double percent sign '%%'. If that works,
> the my theory might be right.
Nope, using '%%' just results in two corrupted signs in the PDF.
Best,
-Nikolaus
--
»Time flies like an arrow, fruit flies like a Banana.«
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
|