{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Combine visualization helpers\n",
"\n",
"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`."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from cartoframes.auth import set_default_credentials\n",
"\n",
"set_default_credentials('cartoframes')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from cartoframes.viz import Map, Layer, size_continuous_style, color_category_style, color_bins_legend\n",
"\n",
"Map([\n",
" Layer(\n",
" 'sf_nbhd',\n",
" style=color_category_style('name', 'SF Neighborhoods',\n",
" cat=[\n",
" 'Downtown/Civic Center',\n",
" 'South of Market',\n",
" 'Mission',\n",
" 'Western Addition',\n",
" 'Financial District','Bayview'\n",
" ],\n",
" palette='[#E58606,#5D69B1,#52BCA3,#99C945,#CC61B0,#ED645A],#ccc',\n",
" stroke_color='#c4c4c4'\n",
" ),\n",
" legends=color_bins_legend(\n",
" description='Hover each to see total crime reports',\n",
" footer='Source: City of SF',\n",
" ascending=True\n",
" )\n",
" ),\n",
" Layer(\n",
" 'sf_nbhd_crime',\n",
" style=size_continuous_style(\n",
" 'value',\n",
" size_range=[8,60],\n",
" opacity=0.05,\n",
" color='black',\n",
" stroke_color='#ffea00',\n",
" stroke_width=2\n",
" ),\n",
" default_legend=False\n",
" )\n",
"])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}