2017-07-04 6 views
1

matplotlib.pyplotを使用してFigureのタイトルを2行に分割する必要があります。matplotlib非アスキー文字とLaTeX文字の2行でタイトルを分割する

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 éèàéüöëêâûô") 

どちらのステートメントのバージョンは私にいくつかのエラーが返されました:ここ

は、私がこれまで試したものです。

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 éèàéüöëêâûô") 

か試してみてください:

答えて

1

[OK]を、私は最終的にそれが仕事ができる唯一の方法を考え出しましたDimgoldも同様ですが、LaTeX文字がない場合にのみ機能します。

LaTeX charが必要な場合は、以前に 'r'タグで文字列をタイプセットする必要があります。
その後、改行文字 '\ n'はもう使用できません。

さらに、__future__から一部をインポートする必要があります。

#!/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 éèàéüöëêâûô""") 
+0

あなたの場合は、代わりに単一のもので、入力した二重を使用この場合:ここで

は私のための有効なソリューションです – Dimgold

1

ちょうど"とライン終わらないと

ありがとう:

plt.title(u"""Some very long string with non ascii chara éèàéüöëêâûô 
and the next line should be here, with maybe some LaTeX symbols like greek letters in addition éèàéüöëêâûô""") 
関連する問題