はじめに
matplotlibのax.legend()で表示できる凡例で、凡例ボックス内の凡例表示位置を調整する方法について説明する。
コード&解説
モジュールのインポートなど
バージョン
データの生成
判例box内で左に寄せて表示
ax.legend()でax.legend(alignment=”left”)とすると以下のようになる。

判例box内の中央に表示
ax.legend()でax.legend(alignment=”center”)とすると以下のようになる。

判例box内で右に寄せて表示
ax.legend()でax.legend(alignment=”right”)とすると以下のようになる。

参考
What's new in Matplotlib 3.6.0 (Sep 15, 2022) — Matplotlib 3.10.0 documentation
コメント