Size category legend

The size-category type draws a legend based on categorical data and geometry type using either the size (default) or stroke_width property of your visualization.

To view available legend parameters, run help(size_category_legend)

In this example, the size category legend reads from the size property to draw a legend with symbol sizes assigned to categories of cities.


In [1]:
from cartoframes.auth import set_default_credentials
from cartoframes.viz import Layer, size_category_style, size_category_legend

set_default_credentials('cartoframes')

In [2]:
Layer(
    'spain_populated_places',
    size_category_style(
        'featurecla',
        cat=['Populated place','Admin-1 capital', 'Admin-0 capital'],
        size_range=[3,7,15]
    ),
    legends=size_category_legend(
        title='Spanish Cities',
        footer='Source: Natural Earth'
    )
)


Out[2]:
Source: Natural Earth
:
StackTrace
    ">