I will give you an example based on my comment above:
You have something like this:
import matplotlib.pyplot as plt %matplotlib inline legend = "\xe2" plt.plot(range(5), range(5)) plt.legend([legend])
that leads to:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
As I said, this is because matplotlib wants to use unicode strings. Thus, in the process of plotting, matplotlib tries to decode your string in order to convert it to Unicode using decode . However, decode has ascii as the default encoding, and since your character is not ascii , an error is displayed. The solution is to decode the string yourself with the appropriate encoding:
import matplotlib.pyplot as plt %matplotlib inline legend = "\xe2".decode(encoding='latin-1') plt.plot(range(5), range(5)) plt.legend([legend])

By the way, regarding using ipython notebook --matplotlib inline , this is considered bad practice because you are hiding what you did to get the resulting laptop. It is much better to include %matplotlib inline in your notebook.
source share