2011-12-01から1日間の記事一覧

Matplotlib で tex 形式のテキストを入力する

いつも忘れてしまうのでメモしておく matplotlib を使って図を作ってるときに,tex 形式のテキストをいれたいときに行う環境変数の設定. from matplotlib import rc rc('text', usetex=True) これで使いたいところで r"$\log\left( h^{-1} M/ M_{\odot}\rig…

内包表現

これが分かりやすいかは別として,テキストファイルととかから読み込んだデータを配列に格納する. p=re.compile("[\t\n]") data = numpy.array( \ map( lambda x: map(lambda y: float(y), p.split(x)), \ [ \ filter( lambda x: x is not "", x) \ for x i…