keisukeのブログ

***乱雑です!自分用のメモです!*** 統計や機械学習の勉強と、読み物を書く練習と、備忘録用のブログ

matplotlib

【matplotlib】日本語の設定

Matplotlibで日本語を出力するのにかなり手間取ったのでメモ。 Windows, Python3を想定しています。

matplotlibのArtistの階層構造

matplotlibのArtist(ユーザが意識して使っているクラス、FigureとかAxesとかAxisとか)は普通は階層構造を持つことになる。 例えば次のように図を作ると: >>> fig = plt.figure() >>> ax1 = fig.add_subplot(211) >>> line = ax1.plot(np.sin(np.arange(0,10…

matplotlib.axes.Axesのhelper methodsで作られたArtistsがどのcontainerに格納されるか

参考:Artist tutorial — Matplotlib 1.4.2 documentationmatplotlib.axes.Axes(一番良く使うArtists:subplotとか)のhelper methods(bar, plot, scatterなど)で作られたArtistsがどのcontainerに格納されるか: Helper method Artist Container Axes.annota…

matplotlibで背景の色や透明度を設定する - How to set the background color and transparency in matplotlib

参考:matplotlib公式のArtist tutorial JP matplotlibでプロットの背景の色や透明度の設定方法: >>> import matplotlib.pyplot as plt >>> fig = plt.figure() # Figure >>> ax = fig.add_subplot(211) # Axes >>> fig.patch.set_facecolor('blue') # 図全…

【Python】ふたつの配列からすべての組み合わせを評価

引数をふたつとる関数f([x,y])が存在するとします(この場合は引数2つではなく、要素数2の配列をひとつ引数にとるのほうが正しいですが・・・)。 たとえば、f([x,y]) = x+y などです。 このfはうまく実装されているので、f([[1,3], [2,4]])とすると(つまり[1+…

matplotlibのplotの種類

pyplot — Matplotlib 1.4.0 documentationplt.plotの引数である,linestyleとcolor,markerの実際のプロット例. plt.plot(x, y, linestyle='-', color='b', marker='.')などと指定する. plt.plot(x, y, 'b.-')などと同時に指定もできる. import numpy as n…