Multiple legends

In this example, there are two legends for one layer. The first legend color-bins reads from the color property of the visualization and the second, size-bins from the width property.


In [1]:
from cartoframes.auth import set_default_credentials
from cartoframes.viz import Map, Layer, color_category_style, size_bins_style, \
                            color_category_legend, size_bins_legend

set_default_credentials('cartoframes')

In [2]:
Map([
    Layer(
        'sf_road_travel',
        style=size_bins_style('auto_speed', opacity=0.5, color='pink'),
        legends=size_bins_legend(
            title='Road Travel Speed',
            footer='Data: City of SF'
        )
    ),
    Layer(
        'sf_road_travel',
        style=color_category_style('direction', palette='bold'),
        legends=color_category_legend(
            title='Road Travel Direction'
        )
    )
])


Out[2]:
Data: City of SF
:
StackTrace
    ">
    
    
    In [3]:
    Map([
        Layer(
            'sf_road_travel',
            title='Road Travel Speed',
            style=size_bins_style('auto_speed', opacity=0.5, color='pink'),
            legends=size_bins_legend(
                footer='Data: City of SF'
            )
        ),
        Layer(
            'sf_road_travel',
            title='Road Travel Speed',
            style=color_category_style('direction', palette='bold')
        )
    ],
    layer_selector=True)
    
    
    
    
    Out[3]:
    Data: City of SF
    :
    StackTrace
      ">