Creating a graduated color visualization

This code will manually assign colors to specific sections of the data, breaking the data into categories. This also assigns specific radius sizes to data so that the visualization will convey information with both color and circle size:

color_stops = [    [0.0, 'rgb(107,174,214)'],    [3000.0, 'rgb(116,196,118)'],    [8000.0, 'rgb(254,153,41)'],    [max(tract_points['Total Population']), 'rgb(222,45,38)'], ]minmax = [min(tract_points['Percent Male']),          max(tract_points['Percent Male'])]diff = minmax[1] - minmax[0]radius_stops = [    [round(minmax[0],2), 4.0],    [round(minmax[0]+(diff/6.0),2), 7.0],    [round(minmax[1]-(diff/2.0),2), 10.0],    [minmax[1], 15.0],]

With these radius sizes and color ranges set, they can be applied ...

Get Mastering Geospatial Analysis with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.