Issue
I need to split a figure title to two lines using matplotlib.pyplot
with non ascii characters in it.
Here's what I've tried so far:
plt.title(u"Some very long string with non ascii chara éèàéüöëêâûô\n"
"and the next line should be here, with maybe some LaTeX symbols like greek letters in addition éèàéüöëêâûô")
plt.title(r"Some very long string with non ascii chara éèàéüöëêâûô\n"
"and the next line should be here, with maybe some LaTeX symbols like greek letters in addition éèàéüöëêâûô")
Both statement versions returned me some errors.
Solution
Ok, I finally figured out the only way it could work:
Thanks to Dimgold for its working solution as well but it works only when there is no LaTeX characters.
When you need LaTeX char, you must typeset the string with the 'r' tag before.
Then, newline character '\n' won't work anymore.
And you must import some extra from __future__
.
Here is the valid solution for me:
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
from __future__ import unicode_literals # It seems absolutely needed.
# some stuff to plot here
plt.title(r"""Some very long string with non ascii chara éèàéüöëêâûô
and the next line should be here, with maybe some LaTeX symbols like $\alpha$ or $\overrightarrow{vector}$ in addition éèàéüöëêâûô""")
Answered By - s.k
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.