style sheet

たとえば,軸ラベルのフォントの大きさは,スタイルファイルに

xtick.labelsize : small # fontsize of the tick labels

ytick.labelsize : small # fontsize of the tick labels

あるいは

xtick.labelsize : 10 # fontsize of the tick labels

ytick.labelsize : 10 # fontsize of the tick labels

として設定することができる.また,基本となるスタイルファイルを変更したくない場合には,作業用ディレクトリにスタイルファイルを置いて,full pathでスタイルファイルを読み込んでもよい.

自分のスタイルシートは,mystyle.mplstyle などの拡張子がmplstyleであるスタイルシートのファイルを作り,同ファイルをmatplotlibの設定ファイルであるmatplotlibrcが存在するフォルダの直下に,stylelibというフォルダを作ってその中に格納する.matplotlibrcが存在するフォルダは

import matplotlib as mpl

mpl.matplotlib_fname()

で調べることができる.自分のスタイルシートを利用するには

> plt.style.use('mystyle')

とすればよい.

matplotlibで描かれる図を細かくコントロールするパラメータのかなりが,スタイルシートに記述されている.また,matplotlibでは複数のスタイルシートが用意されている.したがって,適切なスタイルシートを選択するか,あるいは自分でスタイルシートに記述されている内容の一部を,自分用のスタイルシートに書く,というどちらかの方法で,それらのパラメータのコントロールを行うことになる.

利用可能なスタイルシートの名前は

print(plt.style.available)

で表示させることができる.

A considerable amount of parameters for fine control over the drawing drawn with matplotlib are described in the style sheet. Also, matplotlib provides multiple style sheets. Therefore, either by selecting an appropriate style sheet or by writing a part of the content described in the style sheet on your style sheet, you can control those parameters.

The names of the available style sheets are shown by

> print (plt.style.available)

For your own style sheet, make a file of a style sheet whose extension is mplstyle such as mystyle.mplstyle, and create a folder named stylelib just under the folder where matplotlibrc which is the configuration file of matplotlib exists, . The folder where matplotlibrc exists is shown by

> import matplotlib as mpl

> mpl.matplotlib_fname ()

You can use your own style sheet by calling

> plt.style.use('mystyle')

For example, the fontsize of axis tick labels can be changed by setting

xtick.labelsize : small # fontsize of the tick labels

ytick.labelsize : small # fontsize of the tick labels

or

xtick.labelsize : 10 # fontsize of the tick labels

ytick.labelsize : 10 # fontsize of the tick labels

If you do not want to modify your basic style file, you can put another style file in a working directory and refer it with a full path.