{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from cartoframes.auth import set_default_credentials\n", "from cartoframes.viz.helpers import color_category_layer, color_bins_layer, color_continuous_layer, \\\n", " size_category_layer, size_bins_layer, size_continuous_layer, animation_layer\n", "from cartoframes.viz import Map\n", "\n", "set_default_credentials('cartovl')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Order\n", "- color category\n", "- color bins\n", "- color continuous\n", "- size bins\n", "- size continuous\n", "- size category" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "scrolled": false }, "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", " City of San Francisco\n", " \n", " \n", " \n", " \n", " \n", "
\n", "
\n", "
\n", " \n", "
\n", "
\n", "
\n", "\n", " \n", "\n", "
\n", "

There is a \n", " from the CARTO VL library:

\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": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Color category layer\n", "\n", "# -Simplest version\n", "Map(\n", " color_category_layer('sf_neighborhoods', 'name')\n", ")\n", "\n", "# -With all params\n", "Map(\n", " color_category_layer('sf_neighborhoods', \n", " 'name', \n", " 'Neighborhoods', \n", " top=5, \n", " palette='bold', \n", " description='By Name', \n", " footer='City of San Francisco'\n", " )\n", ")\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "scrolled": false }, "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", " Data source: City of SF\n", " \n", " \n", " \n", " \n", " \n", "
    \n", "
    \n", "
    \n", " \n", "
    \n", "
    \n", "
    \n", "\n", " \n", "\n", "
    \n", "

    There is a \n", " from the CARTO VL library:

    \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": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Color category (polygon)\n", "\n", "# -Simplest version\n", "Map(\n", " color_category_layer('sf_neighborhoods', 'name')\n", ")\n", "\n", "# -With all params and custom category buckets\n", "Map(\n", " color_category_layer('sf_neighborhoods', \n", " 'name', \n", " 'Neighborhoods',\n", " cat=['Bayview', 'Marina'],\n", " palette='[red, blue]',\n", " description='By Name', \n", " footer='Data source: City of SF'\n", " )\n", ")\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": false }, "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", " Data: City of SF\n", " \n", " \n", " \n", " \n", " \n", "
      \n", "
      \n", "
      \n", " \n", "
      \n", "
      \n", "
      \n", "\n", " \n", "\n", "
      \n", "

      There is a \n", " from the CARTO VL library:

      \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": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Color category lines\n", "\n", "# -Simplest version\n", "Map(\n", " color_category_layer('sfcta_congestion_roads', 'direction')\n", ")\n", "\n", "# -With all params\n", "Map(\n", " color_category_layer(\n", " 'sfcta_congestion_roads', \n", " 'direction', \n", " 'Roads', \n", " top=4, \n", " palette='bold', \n", " description='Direction Traveled', \n", " footer='Data: City of SF'\n", " )\n", ")\n", "\n", "# -With all params and custom categories\n", "Map(\n", " color_category_layer(\n", " 'sfcta_congestion_roads', \n", " 'direction', \n", " 'Roads', \n", " cat=['N','S'], \n", " palette='[blue,orange]', \n", " description='Direction Traveled', \n", " footer='Data: City of SF'\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "scrolled": false }, "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", "

        There is a \n", " from the CARTO VL library:

        \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": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Color bins helper\n", "\n", "# -Simplest version\n", "Map(\n", " animation_layer('populated_places', 'pop_max')\n", ")\n", "\n", "# -With all params\n", "Map(\n", " animation_layer(\n", " 'populated_places', \n", " 'pop_max', \n", " duration= 8,\n", " stroke_width=0.25,\n", " stroke_color='yellow',\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "scrolled": false }, "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", " Data: Natural Earth\n", " \n", " \n", " \n", " \n", " \n", "
          \n", "
          \n", "
          \n", " \n", "
          \n", "
          \n", "
          \n", "\n", " \n", "\n", "
          \n", "

          There is a \n", " from the CARTO VL library:

          \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": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Color bins helper\n", "\n", "# -Simplest version\n", "Map(\n", " color_bins_layer('south_america_country', 'pop_est')\n", ")\n", "\n", "# -With custom class breaks\n", "Map(\n", " color_bins_layer(\n", " 'south_america_country', \n", " 'pop_est', \n", " 'Pop est',\n", " breaks=[1000000, 5000000, 10000000],\n", " palette='purpor', \n", " description='By country', \n", " footer ='Data: Natural Earth')\n", ")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "scrolled": false }, "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", " Data: Natural Earth\n", " \n", " \n", " \n", " \n", " \n", "
            \n", "
            \n", "
            \n", " \n", "
            \n", "
            \n", "
            \n", "\n", " \n", "\n", "
            \n", "

            There is a \n", " from the CARTO VL library:

            \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": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Color continuous\n", "\n", "# -Simplest version\n", "Map(\n", " color_continuous_layer('south_america_country', 'pop_est')\n", ")\n", "\n", "# -With all params\n", "Map(\n", " color_continuous_layer(\n", " 'south_america_country', \n", " 'pop_est', \n", " 'Pop est', \n", " palette='sunset',\n", " description='By country', \n", " footer ='Data: Natural Earth'\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "scrolled": false }, "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", " Datasource: US Census Bureau\n", " \n", " \n", " \n", " \n", " \n", "
              \n", "
              \n", "
              \n", " \n", "
              \n", "
              \n", "
              \n", "\n", " \n", "\n", "
              \n", "

              There is a \n", " from the CARTO VL library:

              \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": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Size continuous\n", "\n", "# -Simplest version\n", "Map(\n", " size_continuous_layer('county_points_with_population', 'estimate_total')\n", ")\n", "\n", "# -With all params\n", "Map(\n", " size_continuous_layer(\n", " 'county_points_with_population', \n", " 'estimate_total', \n", " 'Population', \n", " size=[2,50],\n", " description='By US County', \n", " footer ='Datasource: US Census Bureau'\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "scrolled": false }, "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", " Data: City of SF\n", " \n", " \n", " \n", " \n", " \n", "
                \n", "
                \n", "
                \n", " \n", "
                \n", "
                \n", "
                \n", "\n", " \n", "\n", "
                \n", "

                There is a \n", " from the CARTO VL library:

                \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": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Size continuous (lines)\n", "\n", "# -Simplest version\n", "Map(\n", " size_continuous_layer('sfcta_congestion_roads', 'auto_speed')\n", ")\n", "\n", "# -With all params\n", "Map(\n", " size_continuous_layer(\n", " 'sfcta_congestion_roads', \n", " 'auto_speed', \n", " 'Roads', \n", " size=[1,20], \n", " color='green',\n", " description='Sized by travel speed', \n", " footer ='Data: City of SF'\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "scrolled": false }, "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", " Data: US Census Bureau\n", " \n", " \n", " \n", " \n", " \n", "
                  \n", "
                  \n", "
                  \n", " \n", "
                  \n", "
                  \n", "
                  \n", "\n", " \n", "\n", "
                  \n", "

                  There is a \n", " from the CARTO VL library:

                  \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": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Size bins (points)\n", "\n", "# -Simplest version\n", "Map(\n", " size_bins_layer('county_points_with_population', 'estimate_total')\n", ")\n", "\n", "# -With all params\n", "Map(\n", " size_bins_layer(\n", " 'county_points_with_population', \n", " 'estimate_total', \n", " 'Population Estimates',\n", " method='equal',\n", " size=[5,20], \n", " color='brown',\n", " description='By US County', \n", " footer ='Data: US Census Bureau'\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "scrolled": false }, "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", " Data: City of SF\n", " \n", " \n", " \n", " \n", " \n", "
                    \n", "
                    \n", "
                    \n", " \n", "
                    \n", "
                    \n", "
                    \n", "\n", " \n", "\n", "
                    \n", "

                    There is a \n", " from the CARTO VL library:

                    \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": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Size bins (lines)\n", "\n", "# -Simplest version\n", "Map(\n", " size_bins_layer('sfcta_congestion_roads', 'auto_speed')\n", ")\n", "\n", "# -With all params\n", "Map(\n", " size_bins_layer(\n", " 'sfcta_congestion_roads', \n", " 'auto_speed', \n", " 'Roads',\n", " method='quantiles',\n", " bins=3, \n", " size=[1,5,10], \n", " color='blue',\n", " description='Sized by travel speed', \n", " footer ='Data: City of SF'\n", " )\n", ")\n", "\n", "# -With all params and custom class breaks\n", "Map(\n", " size_bins_layer(\n", " 'sfcta_congestion_roads', \n", " 'auto_speed', \n", " 'Roads', \n", " breaks=[10,50,70], \n", " size=[1,5,10], \n", " color='blue',\n", " description='Sized by travel speed', \n", " footer ='Data: City of SF'\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 12, "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", " Data: City of SF\n", " \n", " \n", " \n", " \n", " \n", "
                      \n", "
                      \n", "
                      \n", " \n", "
                      \n", "
                      \n", "
                      \n", "\n", " \n", "\n", "
                      \n", "

                      There is a \n", " from the CARTO VL library:

                      \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": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Size category\n", "\n", "# -Simplest version\n", "Map(\n", " size_category_layer('sfcta_congestion_roads', 'direction')\n", ")\n", "\n", "# -With all params\n", "Map(\n", " size_category_layer(\n", " 'sfcta_congestion_roads', \n", " 'direction', \n", " 'Roads', \n", " cat=['N','S','E','W'], \n", " size=[2,4,6,8],\n", " description='Sized by use', \n", " footer ='Data: City of SF'\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "def color_category_layer(\n", " source, value, title='', top=11, cat=None, palette=None,\n", " size=None, opacity=None, stroke_color=None, stroke_width=None,\n", " description='', footer='', legend=True, popup=True,\n", " widget=False, animate=None):\n", " \"\"\"Helper function for quickly creating a category color map.\n", "\n", " Args:\n", " source (:py:class:`Dataset ` or str): Dataset\n", " or text representing a table or query associated with user account.\n", " value (str): Column to symbolize by.\n", " title (str, optional): Title of legend.\n", " top (int, optional): Number of category for map. Default is 11. Values\n", " can range from 1 to 16.\n", " cat (str, optional): Category list. Must be a valid CARTO VL category\n", " list.\n", " palette (str, optional): Palette that can be a named CARTOColor palette\n", " or other valid CARTO VL palette expression. Default is `bold`.\n", " size (int, optional): Size of point or line features.\n", " opacity (int, optional): Opacity value for point color and line features.\n", " Default is '0.8'.\n", " stroke_width (int, optional): Size of the stroke on point features.\n", " stroke_color (str, optional): Color of the stroke on point features.\n", " Default is '#222'.\n", " description (str, optional): Description text legend placed under legend title.\n", " footer (str, optional): Footer text placed under legend items.\n", " legend (bool, optional): Display map legend: \"True\" or \"False\".\n", " Set to \"True\" by default.\n", " popup (bool, optional): Display popups on hover and click: \"True\" or \"False\".\n", " Set to \"True\" by default.\n", " widget (bool, optional): Display a widget for mapped data.\n", " Set to \"False\" by default.\n", " animate (str, optional): Animate features by date/time or other numeric field.\n", "\n", " Returns:\n", " cartoframes.viz.Layer: Layer styled by `value`.\n", " Includes a legend, popup and widget on `value`.\n", " \"\"\"\n", " func = 'buckets' if cat else 'top'\n", " default_palette = 'bold'\n", " animation_filter = 'animation(linear(${}), 20, fade(1,1))'.format(animate) if animate else '1'\n", "\n", " return Layer(\n", " source,\n", " style={\n", " 'point': {\n", " 'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(\n", " func, value, cat or top, serialize_palette(palette) or default_palette,\n", " opacity or '1'),\n", " 'width': '{0}'.format(\n", " size or defaults.STYLE['point']['width']),\n", " 'strokeColor': '{0}'.format(\n", " stroke_color or defaults.STYLE['point']['strokeColor']),\n", " 'strokeWidth': '{0}'.format(\n", " stroke_width or defaults.STYLE['point']['strokeWidth']),\n", " 'filter': animation_filter\n", " },\n", " 'line': {\n", " 'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(\n", " func, value, cat or top, serialize_palette(palette) or default_palette,\n", " opacity or '1'),\n", " 'width': '{0}'.format(\n", " size or defaults.STYLE['line']['width']),\n", " 'filter': animation_filter\n", " },\n", " 'polygon': {\n", " 'color': 'opacity(ramp({0}(${1}, {2}), {3}), {4})'.format(\n", " func, value, cat or top, serialize_palette(palette) or default_palette,\n", " opacity or '0.9'),\n", " 'strokeColor': '{0}'.format(\n", " stroke_color or defaults.STYLE['polygon']['strokeColor']),\n", " 'strokeWidth': '{0}'.format(\n", " stroke_width or defaults.STYLE['polygon']['strokeWidth']),\n", " 'filter': animation_filter\n", " }\n", " },\n", " popup=popup and not animate and {\n", " 'hover': {\n", " 'title': title or value,\n", " 'value': '$' + value\n", " }\n", " },\n", " legend=legend and {\n", " 'type': {\n", " 'point': 'color-category-point',\n", " 'line': 'color-category-line',\n", " 'polygon': 'color-category-polygon'\n", " },\n", " 'title': title or value,\n", " 'description': description,\n", " 'footer': footer\n", " },\n", " widgets=[\n", " animate and {\n", " 'type': 'time-series',\n", " 'value': animate,\n", " 'title': 'Animation'\n", " },\n", " widget and {\n", " 'type': 'category',\n", " 'value': value,\n", " 'title': 'Categories'\n", " }\n", " ]\n", " )\n", "\n" ] } ], "source": [ "from cartoframes.viz.helpers import _inspect\n", "\n", "_inspect(color_category_layer)" ] } ], "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.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }