text_html_output_1.png
from mpl_toolkits.basemap import Basemap

from sklearn.cluster import KMeans

import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

air = pd.read_csv('../input/air_reserve.csv')

airvisit = pd.read_csv('../input/air_visit_data.csv')
airvisit['visit_date'] = pd.to_datetime(airvisit['visit_date']).dt.date

airinfo = pd.read_csv('../input/air_store_info.csv')

from sklearn.cluster import KMeans
import matplotlib.pyplot as plt
kmeans = KMeans(n_clusters=10, random_state=0).fit(airinfo[['longitude', 'latitude']])
airinfo['cluster'] = kmeans.predict(airinfo[['longitude', 'latitude']])

from mpl_toolkits.basemap import Basemap
m = Basemap(projection='aeqd', width=2000000, height=2000000, lat_0=37.5, lon_0=138.2)
cx = [c[0] for c in kmeans.cluster_centers_]
cy = [c[1] for c in kmeans.cluster_centers_]
cm = plt.get_cmap('gist_rainbow')
colors = [cm(2.0 * i / 10) for i in range(10)]
colored = [colors[k] for k in airinfo['cluster']]
f, axa = plt.subplots(1, 1, figsize=(15, 16))
m.drawcoastlines()
m.fillcontinents(color='lightgray', lake_color='aqua', zorder=1)
m.scatter(airinfo.longitude.values, airinfo.latitude.values, color=colored, s=20, alpha=1, zorder=999, latlon=True)
m.scatter(cx, cy, color='Black', s=50, alpha=1, latlon=True, zorder=9999)
plt.setp(axa.get_yticklabels(), visible=True)
plt.annotate('Fukuoka', xy=(0.04, 0.32), xycoords='axes fraction', fontsize=20)
plt.annotate('Shikoku', xy=(0.25, 0.25), xycoords='axes fraction', fontsize=20)
plt.annotate('Hiroshima', xy=(0.2, 0.36), xycoords='axes fraction', fontsize=20)
plt.annotate('Osaka', xy=(0.4, 0.3), xycoords='axes fraction', fontsize=20)
plt.annotate('Tokyo', xy=(0.6, 0.4), xycoords='axes fraction', fontsize=20)
plt.annotate('Shizoku', xy=(0.5, 0.32), xycoords='axes fraction', fontsize=20)
for i in range(len(cx)):
    xpt, ypt = m(cx[i], cy[i])
    plt.annotate(i, (xpt + 500, ypt + 500), zorder=99999, fontsize=16)
plt.show()