Forum Archive

Matplotlib unicode(Greek) letters

miou1974

Is it possible to have Greek letters in titles and legends of matplotlib? I have tried various methods without success

Phuket2

Sorry, I could not help myself. Can't answer your question, but it would be a little strange if it was not possible given so much mathematics are Greek.

miou1974

Actually it is possible to print Greek letters for math expressions by using r'$\Delta$' for Δ for example but i want to use free Greek text like u'Ψωμί'.

JonB

I have not tried it, but you might try:

matplotlib.rcParams['text.usetex'] = True
matplotlib.rcParams['text.latex.unicode'] = True

You could also try setting usetex to false.

I don't know if the backend that comes with pythonista supports unicode or not.

ccc

The matplotlib Unicode demo works out of the box with accents, umlauts, etc. but those pesky Greek characters just appear as squares.

Webmaster4o

@ccc Greek. Typo there. Try this http://stackoverflow.com/questions/13338550/typing-greek-letters-etc-in-python-plots

ccc

I fixed the typo. I had already looked at that stack overflow page but I still could not get it to work.

miou1974

The following may work:
matplotlib.pyplot.rc('font', family='arial')
How can I find the fonts supported by iPad?
Arial does not work on ipad but I managed to print Greek letters on Windows this way.

Webmaster4o

@miou1974 There has been past discussion on this, search the forum for "font". Also, iosfonts.com

ccc

How can I find the fonts supported by iPad?

Open a Pythonista editor can click inside that editor so the insertion cursor is flashing in the text. In the upper left, click on the +-inside-a-box icon. Click "Fonts" at the bottom and scroll thru the fonts. Arial is there but does not do what you want :-( Maybe Symbol or Zapf Dingbats, etc.

miou1974

The following worked for me

matplotlib.pyplot.rc('font', family='STIXGeneral')