0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Python】Matplotlibで凡例のラベルを指定する方法

Posted at

凡例はlegendメソッドで描画します。

凡例の文字列は、plotメソッドなどの引数「label」で指定します。

凡例を表示する位置は、legendメソッドの引数「loc」で指定します。

x = [0.0, 1.0]
y = [0.0, 1.0]

fig, ax = plt.subplots()
ax.plot(x, y, label='sample')
ax.legend(loc='best')

image.png
引数「loc」で指定できる位置は、以下の10パターンです。

best
upper left
upper center
upper right
center left
center
center right
lower left
lower center
lower right

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?