はじめに
matplotlibでx軸, y軸の位置を調整する方法について説明する。
コード

解説
モジュールのインポート
バージョン
データの生成と表示
データの生成は下記記事と同様に行った。

[matplotlibで錯視] 3. きらめき格子錯視
matplotlibできらめき格子錯視を作成する。
ラベルの位置の調整
それぞれの図のラベルを表示するにはset_xlabelを用いる。
locを[‘left’,’center’,’right’]のように変化させると、ラベルの位置がそれぞれ、左寄り、中央、右寄りとなる。

ylabelの位置を調整
y軸のラベルはset_ylabelで設定する。[‘bottom’, ‘center’, ‘top’]のように変化させることでy軸ラベルの位置が下寄り、中央、上寄りと変化する。

labelと図の間の間隔を調整
ラベルと図の間の間隔の調整はset_xlabelの中で、labelpadを設定することで可能となる。

参考
What's new? — Matplotlib 3.3.0 documentation
matplotlib.axes.Axes.set_xlabel — Matplotlib 3.3.0 documentation
タイトルの位置の調整
タイトルの位置の調整については、下記記事で解説した。

[matplotlib] 63. タイトルの位置の調整
matplotlibで作成する図にタイトルをつける方法とその位置の設定方法について説明する。
コメント