Using unicode text and axes labels

I need to make plots in which the axes and text labels

    > display in either English, Spanish, or Portuguese.

Does the unicode demo work for you?

http://matplotlib.sourceforge.net/examples/unicode_demo.py

JDH

Hi,

i have nearly the same problem. I need to make plots
in which the text, axea and labels are either in
english, frensh, german, spanish or italian. I use
wxPython and in the main-program it woks with the
languages, but the plots have these little squares in
the text if there has to be a umlaut or special
chracter. The unicode demo works as long as the plot
is not embedded in wxPython. With wxPython only
"self.axes.set_ylabel( unicode('Andr\xc3\xa9 was
here!', 'utf-8') )" is working. The other texts have
some weird characters in it. Here is the code to check
yourself:

# -*- coding: utf_8 -*-

from wxPython.wx import *
import gettext
from pylab import *
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import
FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure

class GraphFrame(wxFrame):
    def __init__(self, parent, ID, title):
        wxFrame.__init__(self, parent, ID, title,
size=(650,450))

        self.figure = Figure()

        self.axes = self.figure.add_subplot(111)

        self.axes.plot([1,2,4])
        self.axes.set_title( unicode('D�velopp�s et
fabriqu�s', 'latin-1') )
        self.axes.set_xlabel( unicode("r�activit� nous
permettent d'�tre s�lectionn�s et adopt�s", 'latin-1')
)
        self.axes.set_ylabel( unicode('Andr\xc3\xa9
was here!', 'utf-8') )
        self.axes.text( 0.5, 2.5, unicode('Institut
f�r Festk�rperphysik', 'latin-1'), rotation=45)
        self.axes.text( 1, 1.5, u'AVA (check
kerning)')

        self.canvas = FigureCanvas(self, -1,
self.figure)
        self.sizer = wxBoxSizer(wxVERTICAL)
        self.sizer.Add(self.canvas, 1, wxLEFT | wxTOP

wxGROW)

        self.SetSizer(self.sizer)
        self.Fit()
        
class MyApp(wxApp):
    def OnInit(self):

        # Install gettext. Once this is done, all
strings enclosed in "_()" will automatically be
translated.
        gettext.install('MyApp', './locale',
unicode=True)

        # detect the user's default language setting
        loc = wxLocale
        userLang = loc.GetSystemLanguage()

        frame = GraphFrame(None, -1, _("Graph Frame"))
        self.SetTopWindow(frame)
        frame.CentreOnScreen()
        frame.Show(True)
        return True

def main():
    app = MyApp(0)
    app.MainLoop()

if __name__ == '__main__':
    main()

The problem is that i do not know all texts to be
shown, as the name of the user should be written as
title.

I am using Windows XP, Python 2.3, wxPython 2.6.1.0
and Matplotlib 0.85

Thanks

   Till Wagner

--- John Hunter <jdhunter@...4...>
schrieb:

    > I need to make plots in which the axes
and text labels
    > display in either English, Spanish, or
Portuguese.

Does the unicode demo work for you?

http://matplotlib.sourceforge.net/examples/unicode_demo.py

···

JDH

-------------------------------------------------------------------------

Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get
the chance to share your
opinions on IT & business topics through brief
surveys -- and earn cash

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net

--
"Since man's natural instincts lead him to sin, all men are sinners;
and all sinners go to hell. If everyone goes to hell, then you will
meet all your friends there. Heaven must be populated with some
rather strange creatures if all they lived for was to go to a place
where they can stump harps for eternity."- Anton Szandor LaVey
------------------------------------------------------------------------
Till Wagner <sacro_thaan@...9...>

___________________________________________________________
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de