PsycoPulcino
PsycoPulcino

Reputation: 111

Plots with unicode character

I need to put greek letters in labels of a matplotlib plot . how can I do it? For instance, unicode Omega is : u\u03A9. I use plt.xlabel('label')

Upvotes: 0

Views: 590

Answers (2)

James
James

Reputation: 36608

If you are looking specifically for greek letter, you can use LaTex in-line math formatting commands (i.e. '$\Omega$') to produce letter that are in the Latex character map.

import numpy as np
import matplotlib.pyplot as plt
plt.plot(np.arange(1000), np.random.rand(1000), 'b.')
plt.xlabel('$\Omega$', size=16)

enter image description here

Here are good resources for finding LaTex symbols.

Upvotes: 2

af3ld
af3ld

Reputation: 794

I'm not positive about matplotlib, but I would assume that declaring them as unicode strings should work

>>> print u'\u03A9' 
Ω

Upvotes: 1

Related Questions