Hi Everyone,
Not really related to my every day work, but I was asking myself how to put non latin letters, like arabic or hebrew on plots.
I found a way to put german umlauts and ß but this is only a very partial solution. It would be cool to know how to over come this.
My code to work with umlauts is:
#!/usr/bin/env python
-- coding: utf-8 --
import matplotlib.pyplot as plt
import numpy as np
def format(x, pos=None):
if x == 0.0:
exp = 0
else:
exp = int(np.log10(np.abs(x)))
mant = x / 10**exp
return ‘%.1fE%+d’ % (mant, exp)
f = plt.figure()
ax = f.add_subplot(111)
data = np.array([1,2,3,4,5]) / 100.
ax.plot(data, np.arange(len(data)))
ax.xaxis.set_major_formatter(plt.FuncFormatter(format))
ax.yaxis.set_major_formatter(plt.FuncFormatter(format))
ax.text(0.03,0.5,“Umlauts äüöß”+ u"\u00e4")
plt.show()
If I include arabic or hebrew letters I get Bricks displays.
Thanks in advance,
Oz
···
–
Oz Nahum
Graduate Student
Zentrum für Angewandte Geologie
Universität Tübingen
Imagine there’s no countries
it isn’t hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace