Combine visualization helpers

In this example, the size_continuous_style and the color_category_style are used to make a map of crime reports by San Francisco neighborhood. It also shows how to use a color_bins_legend along with the color_category_style.


In [1]:
from cartoframes.auth import set_default_credentials

set_default_credentials('cartoframes')

In [3]:
from cartoframes.viz import Map, Layer, size_continuous_style, color_category_style, color_bins_legend

Map([
    Layer(
        'sf_nbhd',
        style=color_category_style('name', 'SF Neighborhoods',
            cat=[
                'Downtown/Civic Center',
                'South of Market',
                'Mission',
                'Western Addition',
                'Financial District','Bayview'
            ],
            palette='[#E58606,#5D69B1,#52BCA3,#99C945,#CC61B0,#ED645A],#ccc',
            stroke_color='#c4c4c4'
         ),
         legends=color_bins_legend(
             description='Hover each to see total crime reports',
             footer='Source: City of SF',
             ascending=True
         )
    ),
    Layer(
        'sf_nbhd_crime',
        style=size_continuous_style(
            'value',
            size_range=[8,60],
            opacity=0.05,
            color='black',
            stroke_color='#ffea00',
            stroke_width=2
        ),
        default_legend=False
    )
])


Out[3]:
Source: City of SF
:
StackTrace
    ">