Thanks for spotting this.  I don't think a lot of us ever use 
non-English locales, so that's fallen through the cracks.

backend_svg.py was using '%s' to convert floats, to limit the number of 
digits written to the file.  This works fine with regular floats (since 
they do not follow the locale unless explicitly asked to do so), but 
numpy arrays seem to always follow the locale.  (Not certain whether 
that inconsistency could be considered a bug in Numpy).

In any case, I've committed a workaround to matplotlib, which 
unfortunately results in slightly larger SVG files.  This is now fixed 
in SVN r6049.  Look there for a patch if you just want to fix your local 
backend_svg.py.

Cheers,
Mike

Mathieu Leplatre wrote:
> Hi,
>
> If I change the locale using cairo backend, the result is fine.
> But with SVG backend, every objects collapse on top-left corner.
>
> As you can see here :
> http://mathieu-leplatre.info/media/matplotlib-svg/localechange-svg.svg
>
> I exported it to png with inkscape to reveal objects outside of frame :
> http://mathieu-leplatre.info/media/matplotlib-svg/localechange-svg.png
>
> Cairo output is fine :
> http://mathieu-leplatre.info/media/matplotlib-svg/localechange-cairo.svg
>
> I guess it's not a unicode problem, since the strings have no
> non-ascii characters.
>
> The code is quite straightforward, it allows me to choose the date
> language for the formatters.
> Let me know if I should fill a bug report.
> Thank you all !
>
> ----
> import locale, matplotlib
> from datetime import datetime
> matplotlib.use('svg')
> import pylab, numpy
>
> locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
> today = datetime.today().strftime("%A")
>
> pylab.title( today )
> pylab.plot( range(10), numpy.random.randn( 10 ))
> pylab.savefig('localechange-%s' % matplotlib.get_backend())
> ----
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to