Automatically setting colors, sizes, and breaks

Instead of manually setting the colors, radius sizes, and breaks, MapboxGL—Jupyter includes utilites (such as create_color_stops) that create a match between colors (or sizes) and break values. The color schema is set by passing the YlOrRd keyword ( which means Yellow Orange Red). Also, we can adjust the basemap using another pre-set style or our own custom styles by setting the visualization style to the style URL:

measure_color = 'Percent Male'
color_breaks = [round(tract_points[measure_color].quantile(q=x*0.1),3) for x in range(1, 11,3)]
color_stops = create_color_stops(color_breaks, colors='YlOrRd')
measure_radius = 'Total Population'
radius_breaks = [round(tract_points[measure_radius].quantile(q=x*0.1),1) for x in range(2, 12,2)]
radius_stops = create_radius_stops(radius_breaks, 5.0, 20)
vizGrad = GraduatedCircleViz('tract_points2.geojson',
access_token=token,
color_property = measure_color,
color_stops = color_stops,
radius_property = measure_radius,
radius_stops = radius_stops,
stroke_color = 'black',
stroke_width = 0.5,
center = (-122, 37.75),
zoom = 9,
opacity=0.75)
vizGrad.style='mapbox://styles/mapbox/dark-v9'
vizGrad.show()

The dark basemap allows for the graduated circle visualizations to be more clearly seen:

Explore the visualization options available in the documentation here:
https://github.com/mapbox/mapboxgl-jupyter/blob/master/docs-markdown/viz.md.

Explore the data utilities available here:
https://github.com/mapbox/mapboxgl-jupyter/blob/master/docs-markdown/utils.md.

Explore the color ramps available here:
https://github.com/mapbox/mapboxgl-jupyter/blob/master/mapboxgl/colors.py.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset