SourceForge logo
SourceForge logo
Menu

Re: [Matplotlib-users] SVG backend fails with locale change

From: Michael D. <md...@st...> - 2008年08月25日 22:17:32
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
> Mat...@li...
> 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

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /