|
From: Ojala J. <jan...@aa...> - 2013-05-15 10:40:55
|
I have a weird problem with Unicode strings. I am using windows 7 with Python 2.7.2 64 bit, and matplotlib 1.2.1 (package from Unofficial Windows Binaries at http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib ). When i run: -*- coding: utf-8 -*- import matplotlib.pyplot as plt fig = plt.figure( ) ax = fig.add_subplot(111) ax.hist([1,2,3,4,5,6,7,8,9,10], bins=range(1,11) ) plt.ylabel(u'ä') fig.savefig('test.eps') I get a crash: >pythonw -u "bugtest.py" >Exit code: -1073740777 but if i modify my code to read: -*- coding: utf-8 -*- import matplotlib.pyplot as plt fig = plt.figure( ) ax = fig.add_subplot(111) ax.hist([1,2,3,4,5,6,7,8,9,10], bins=range(1,11) ) plt.ylabel(u'äł') fig.savefig('test.eps') Then no longer crashes. Why is it that "a umlaut" alone crashes but when the string contains a "l stroke" character the Unicode string behaves fine. In both cases it works fine if I show the plot but not when I write eps either in code or when saving. |
|
From: Alexander E. <ale...@ov...> - 2013-05-15 11:54:44
|
On Wed, 15 May 2013 10:40:47 +0000 Ojala Janne <jan...@aa...> wrote: ['ä' Umlaut] > >pythonw -u "bugtest.py" > >Exit code: -1073740777 My installation (Python 2.6.6, MPL 1.2.1) is a bit more helpful with error messages: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 269: ordinal not in range(128) A similar error is raised with the other character you suggested. Unfortunately, I do not know about MPL's limitations related to unicode labels. I use "text.usetex : True" in my matplotlibrc. Regards Alex -- Alexander Eberspächer Theorie der Kondensierten Materie I Otto-von-Guericke-Universität Magdeburg Fon: +49 391 67 11339 |
|
From: Ojala J. <jan...@aa...> - 2013-05-15 12:58:47
|
>> I use "text.usetex : True" in my matplotlibrc. It works if I force it to tex, its still a nasty bug of somekind. What I would like to know what changes in the processing when you have both those characters present? Does it fallback to tex use at some point? If so why does it not fallback for ä automatically. |
|
From: Michael D. <md...@st...> - 2013-05-15 13:33:42
|
Which backend are you using? I can't reproduce. Does https://github.com/matplotlib/matplotlib/blob/master/examples/text_labels_and_annotations/unicode_demo.py work for you? Mike On 05/15/2013 06:40 AM, Ojala Janne wrote: > I have a weird problem with Unicode strings. I am using windows 7 with > Python 2.7.2 64 bit, and matplotlib 1.2.1 (package from Unofficial Windows > Binaries at http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib ). > > When i run: > -*- coding: utf-8 -*- > import matplotlib.pyplot as plt > > fig = plt.figure( ) > > ax = fig.add_subplot(111) > ax.hist([1,2,3,4,5,6,7,8,9,10], bins=range(1,11) ) > > plt.ylabel(u'ä') > fig.savefig('test.eps') > > I get a crash: > >> pythonw -u "bugtest.py" >> Exit code: -1073740777 > but if i modify my code to read: > -*- coding: utf-8 -*- > import matplotlib.pyplot as plt > > fig = plt.figure( ) > > ax = fig.add_subplot(111) > ax.hist([1,2,3,4,5,6,7,8,9,10], bins=range(1,11) ) > > plt.ylabel(u'äł') > fig.savefig('test.eps') > > Then no longer crashes. Why is it that "a umlaut" alone crashes > but when the string contains a "l stroke" character the Unicode string > behaves fine. In both cases it works fine if I show the plot but not when > I write eps either in code or when saving. > > > ------------------------------------------------------------------------------ > AlienVault Unified Security Management (USM) platform delivers complete > security visibility with the essential security capabilities. Easily and > efficiently configure, manage, and operate all of your security controls > from a single console and one unified framework. Download a free trial. > http://p.sf.net/sfu/alienvault_d2d > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Ojala J. <jan...@aa...> - 2013-05-15 20:55:47
|
>> Which backend are you using? I can't reproduce. Does >>https://github.com/matplotlib/matplotlib/blob/master/examples/text_labels_and_annotations/unicode_demo.py<https://github.com/matplotlib/matplotlib/blob/master/examples/text_labels_and_annotations/unicode_demo.py> >> work for you? The bug only happens if I try to save the figure as EPS. So I suppose that then means its a cairo back end (happens also if I force cairo). So that means as written the code works fine but if i try to make publishable quality output by saving as EPS (a raster image is not suitable), it crashes. But it again works if I add any character thats so weird that ist on a n extended unicode block then all characters seem to be handled correctly. Even the ones that previously crashed. |
|
From: Christoph G. <cg...@uc...> - 2013-05-15 22:26:35
Attachments:
mpl_umlaut_callstack.txt
|
On 5/15/2013 1:55 PM, Ojala Janne wrote: > >>> Which backend are you using? I can't reproduce. Does > >>>https://github.com/matplotlib/matplotlib/blob/master/examples/text_labels_and_annotations/unicode_demo.py > <https://github.com/matplotlib/matplotlib/blob/master/examples/text_labels_and_annotations/unicode_demo.py> > >>> work for you? > > The bug only happens if I try to save the figure as EPS. So I suppose that > then means its a cairo back end (happens also if I force cairo). So that > means > as written the code works fine but if i try to make publishable quality > output > by saving as EPS (a raster image is not suitable), it crashes. > > But it again works if I add any character thats so weird that ist on a n > extended > unicode block then all characters seem to be handled correctly. Even > the ones > that previously crashed. > I can reproduce the crash on Python 2.7, 32 and 64 bit. Python 2.6 and 3.3 appear to work. The call stack is attached. The crash is in ttfont_add_glyph_dependencies() at <https://github.com/matplotlib/matplotlib/blob/v1.2.x/ttconv/pprdrv_tt2.cpp#L703> Christoph |
|
From: Michael D. <md...@st...> - 2013-05-16 01:17:31
|
I've created an issue in the tracker for this: https://github.com/matplotlib/matplotlib/issues/2016 Mike On 05/15/2013 06:26 PM, Christoph Gohlke wrote: > On 5/15/2013 1:55 PM, Ojala Janne wrote: >> >>>> Which backend are you using? I can't reproduce. Does >> >>>> https://github.com/matplotlib/matplotlib/blob/master/examples/text_labels_and_annotations/unicode_demo.py >>>> >> <https://github.com/matplotlib/matplotlib/blob/master/examples/text_labels_and_annotations/unicode_demo.py> >> >> >>>> work for you? >> >> The bug only happens if I try to save the figure as EPS. So I suppose >> that >> then means its a cairo back end (happens also if I force cairo). So that >> means >> as written the code works fine but if i try to make publishable quality >> output >> by saving as EPS (a raster image is not suitable), it crashes. >> >> But it again works if I add any character thats so weird that ist on a n >> extended >> unicode block then all characters seem to be handled correctly. Even >> the ones >> that previously crashed. >> > > I can reproduce the crash on Python 2.7, 32 and 64 bit. Python 2.6 and > 3.3 appear to work. The call stack is attached. The crash is in > ttfont_add_glyph_dependencies() at > <https://github.com/matplotlib/matplotlib/blob/v1.2.x/ttconv/pprdrv_tt2.cpp#L703> > > Christoph > > > > > > ------------------------------------------------------------------------------ > AlienVault Unified Security Management (USM) platform delivers complete > security visibility with the essential security capabilities. Easily and > efficiently configure, manage, and operate all of your security controls > from a single console and one unified framework. Download a free trial. > http://p.sf.net/sfu/alienvault_d2d > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |