<Python, matplotlib> 散布図の各要素に文字を付ける。
散布図の各要素に文字を付ける方法。ax.annotate()
を使う。
キーワードは、DataFrame
、scatter
、annotate
In [25]:import pandas as pd import numpy as np import matplotlib.pyplot as plt df = pd.DataFrame(np.random.randn(5,2)) In [22]:fig, ax = plt.subplots() df.plot(0,1,kind='scatter',ax=ax) Out[22]: <matplotlib.axes._subplots.AxesSubplot at 0x54b2ac8> In [23]:for k, v in df.iterrows(): ax.annotate(k,xy=(v[0],v[1]),size=20) In [24]:plt.show()
じゃじゃーん。
ここで勉強。 stackoverflow.com
マニュアルはここ。
Annotating Axes — Matplotlib 1.4.3 documentation
API
はここ。matplotlib.axes.Axes.annotate()
axes — Matplotlib 1.4.3 documentation