Reputation:
Data :
Taluka_name Y X
AKOLA 2509.5 103.03
AKOT 2007.8 91.23
BALAPUR 1384.3 109.47
BARSHI 1364.9 92.58
MURTIJAPUR 1209 100.37
PATUR 363.2 103.68
TELHARA 846.9 83.38
I want to draw a scatter plot , where my points will be show me this point for this taluka_name.
I want to display "Taluka_name"with corresponding scatter points.
I tried following code, but I got only scatter points in a graph ,not corresponding "Taluka_name" with points.
Code:
>>> import pandas as pd
>>> import matplotlib.pyplot as plt
>>> data = pd.read_csv('/home/desktop/Desktop/Akola.csv')
>>> df=data.set_index('Taluka_name')
>>> df.plot(kind='scatter', x='X', y='Y')
<matplotlib.axes._subplots.AxesSubplot object at 0x7fc051099390>
>>> plt.show()
Upvotes: 1
Views: 116
Reputation:
I got it,
>>> import pandas as pd
>>> import matplotlib.pyplot as plt
>>> data = pd.read_csv('/home/desktop/Desktop/Akola_kharif.csv')
>>> ax = data.plot.scatter(x='X', y='Y', alpha=0.5)
>>> for i, txt in enumerate(data.Taluka_name):
ax.annotate(txt, (data.X.iat[i],data.Y.iat[i]))
<matplotlib.text.Annotation object at 0x7f668f2fc310>
<matplotlib.text.Annotation object at 0x7f668f2a0710>
<matplotlib.text.Annotation object at 0x7f668f2a0850>
<matplotlib.text.Annotation object at 0x7f668f2a0910>
<matplotlib.text.Annotation object at 0x7f668f2a09d0>
<matplotlib.text.Annotation object at 0x7f668f2a0a90>
<matplotlib.text.Annotation object at 0x7f668f2a0b50>
>>> plt.show()
Upvotes: 1