{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Histogram widget\n", "\n", "Histogram widgets display the distribution of a numeric attribute, in buckets, to group ranges of values in your data. You can hover over each bar to see each bucket's values and count, and filter your map's data within a given range by selecting it. By default, as you zoom or pan the map, the values in the widget update to the current viewport. \n", "\n", "To see available parameters run `help(histogram_widget)`.\n", "\n", "In the example below, the number of vehicles involved in each collision in Seattle are grouped over 9 buckets." ] }, { "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": [ "\n", "\n", "\n", " None\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " Static map image\n", " \n", " \n", " \n", "\n", "\n", " \n", "
\n", "
\n", "
\n", " \n", " \n", "
\n", "
\n", "
\n", "\n", " \n", "\n", "
\n", "
\n", " :\n", "
\n", " \n", " \n", "
\n", "
\n", "\n", "
\n", " StackTrace\n", "
    \n", "
    \n", "
    \n", "\n", "\n", "\n", "\n", "\n", "\">\n", "\n", "" ], "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from cartoframes.viz import Layer, histogram_widget\n", "\n", "Layer(\n", " 'seattle_collisions',\n", " widgets=[\n", " histogram_widget(\n", " 'vehcount',\n", " title='Number of Vehicles Involved',\n", " description='Select a range of values to filter',\n", " buckets=9\n", " )\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 }