# to draw circles for legend circles = pd . read_csv ( 'circles.csv' ) # circles has just five data points set in months 5-9 of the year 1900 circles [[ 'year' , 'month' , 'day' ]] = circles [[ 'year' , 'month' , 'day' ]] . astype ( int ) circles . sort ( 'magnitude' , ascending = True , inplace = True ) prefix = 'circles' alphalist = [ 0.95 , 0.85 , 0.75 , 0.65 , 0.55 , 0.45 , 0.35 ] def get_alpha ( magnitude ): if magnitude < 5.5 : return alphalist [ 0 ] elif magnitude < 6 : return alphalist [ 1 ] elif magnitude < 6.5 : return alphalist [ 2 ] elif magnitude < 7.0 : return alphalist [ 3 ] elif magnitude < 7.5 : return alphalist [ 4 ] elif magnitude < 8.0 : return alphalist [ 5 ] else : return alphalist [ 6 ] for this_year in range ( 1900 , 1901 ): for this_month in range ( 5 , 10 ): plt . figure ( figsize = ( 15 , 10 )) map = Basemap ( projection = 'merc' , lat_0 = 57 , lon_0 = 120 , resolution = 'c' , area_thresh = 0.1 , llcrnrlon = 83 , llcrnrlat = 23 , urcrnrlon = 156 , urcrnrlat = 52 ) map . warpimage ( image = 'darkrelief.jpg' ) tempdf = circles [( circles . year == this_year ) & ( circles . month == this_month )] latlist = list ( tempdf . lat ) lonlist = list ( tempdf . lon ) maglist = list ( tempdf . magnitude ) label = 'Magnitude ' label += str ( this_month ) plt . annotate ( label , xy = ( 0.01 , 0.97 ), ha = 'left' , va = 'top' , xycoords = 'axes fraction' , color = '#ffff33' , fontsize = 35 , fontname = 'Consolas' ) #, bbox=dict(facecolor='#ffffaa', alpha=0.8)) min_marker_size = 20 for lon , lat , mag in zip ( lonlist , latlist , maglist ): x , y = map ( lon , lat ) msize = ( mag - 4.5 ) ** 1.5 * min_marker_size thisalpha = get_alpha ( mag ) map . plot ( x , y , color = '#ffff00' , marker = 'o' , markersize = msize , alpha = thisalpha ) plt . savefig ( prefix + label . replace ( '/' , '' ) + '.png' ) #plt.show() plt . close ()