It's pretty easy to find a way to draw a scatter plot in Pandas. However, I couldn't find a way to display the label on each element as shown below, so make a note of it.
Repeat each row with for in Pandas iterrows () until drawing with aanotate.
scatter-label.py
import pandas as pd
#Set data in DataFrame
dd = pd.DataFrame([
[10,50,'hoge'],
[50,30,'fpp'],
[20,30,'baa']
], columns=['ax','ay','label'])
#Draw a scatter plot
a = dd.plot.scatter(x='ax',y='ay')
#Display a label on each element
for k, v in dd.iterrows():
a.annotate(v[2], xy=(v[0],v[1]), size=15)
Recommended Posts