|
From: Benjamin R. <ben...@ou...> - 2012-10-10 02:32:07
|
On Tuesday, October 9, 2012, Nikolaus Rath wrote:
> Damon McDougall <dam...@pu...<javascript:;>>
> writes:
> > On Tue, Oct 9, 2012 at 10:56 PM, Damon McDougall
> > <dam...@pu... <javascript:;>>
> wrote:
> >> On Tue, Oct 9, 2012 at 10:32 PM, Nikolaus Rath <
> Nik...@pu... <javascript:;>> wrote:
> >>> Hello,
> >>>
> >>> 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,
>
> Best,
>
> -Nikolaus
>
>
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.
In addition, I think it is only in master, not v1.2.x.
Ben Root
|