1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| fig, ax = plt.subplots(figsize=[10, 6]) rs_scatter = ax.scatter(rep_points['lon'][0], rep_points['lat'][0], c='#99cc99', edgecolor='None', alpha=0.7, s=450) ax.scatter(rep_points['lon'][1], rep_points['lat'][1], c='#99cc99', edgecolor='None', alpha=0.7, s=250) ax.scatter(rep_points['lon'][2], rep_points['lat'][2], c='#99cc99', edgecolor='None', alpha=0.7, s=250) ax.scatter(rep_points['lon'][3], rep_points['lat'][3], c='#99cc99', edgecolor='None', alpha=0.7, s=150) df_scatter = ax.scatter(df_min['lng'], df_min['lat'], c='k', alpha=0.9, s=3) ax.set_title('Full GPS trace vs. DBSCAN clusters') ax.set_xlabel('Longitude') ax.set_ylabel('Latitude') ax.legend([df_scatter, rs_scatter], ['GPS points', 'Cluster centers'], loc='upper right') labels = ['cluster{0}'.format(i) for i in range(1, num_clusters+1)] for label, x, y in zip(labels, rep_points['lon'], rep_points['lat']): plt.annotate( label, xy = (x, y), xytext = (-25, -30), textcoords = 'offset points', ha = 'right', va = 'bottom', bbox = dict(boxstyle = 'round,pad=0.5', fc = 'white', alpha = 0.5), arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0')) plt.show()
|