#!/usr/bin/env python # coding: utf-8 # ## Color category legend # The `color-category` type draws a categorical legend on your map that is based on your data's geometry using either the `color` (default) or `strokeColor` property of your visualization. # # To view available legend parameters, run `help(color_category_legend)` # # In this example, the category legend draws the top 3 tree species types in San Francisco. # In[1]: from cartoframes.auth import set_default_credentials set_default_credentials('cartoframes') # In[2]: from cartoframes.viz import Layer, color_category_style, color_category_legend Layer( 'trees_sf', color_category_style('common_species', top=3), legends=color_category_legend( title='Trees in San Francisco', description='Top 3 species', footer='Data: City of SF' ) )