{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from cartoframes.auth import set_default_credentials\n", "from cartoframes.viz import Map, Layer, Source, Style, Legend\n", "\n", "set_default_credentials('cartovl')" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " CARTOframes\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", " \n", " \n", " \n", " \n", " \n", " [footer]\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", "" ], "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Legend color\n", "map = Map(\n", " Layer(\n", " Source('populated_places'),\n", " Style('color: ramp(top($adm0name, 5), bold)'),\n", " legend=Legend({\n", " 'type': 'color-category',\n", " 'title': '[TITLE]',\n", " 'description': '[description]',\n", " 'footer': '[footer]'\n", " })\n", " )\n", ")\n", "\n", "# Legend color + sugar\n", "Map(\n", " Layer(\n", " 'populated_places',\n", " 'color: ramp(top($adm0name, 5), bold)',\n", " legend={\n", " 'type': 'color-category',\n", " 'title': '[TITLE]',\n", " 'description': '[description]',\n", " 'footer': '[footer]'\n", " }\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " CARTOframes\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", " \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", "" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Legend strokeColor\n", "Map(\n", " Layer(\n", " 'populated_places',\n", " 'color: transparent strokeWidth: 1 strokeColor: ramp(top($adm0name, 5), bold)',\n", " legend={\n", " 'type': 'color-category',\n", " 'prop': 'strokeColor',\n", " 'title': '[TITLE]',\n", " 'description': '[description]'\n", " }\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " CARTOframes\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", " \n", " \n", " \n", " \n", " \n", " [footer]\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", "" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Legend: only info\n", "Map(\n", " Layer(\n", " 'populated_places',\n", " legend={\n", " 'title': '[TITLE]',\n", " 'description': '[description]',\n", " 'footer': '[footer]'\n", " }\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " CARTOframes\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", " \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", "" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Legend: color\n", "Map(\n", " Layer(\n", " 'populated_places',\n", " legend={\n", " 'type': 'color-category'\n", " }\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " CARTOframes\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", " \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", "" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Legend: size\n", "Map(\n", " Layer(\n", " 'populated_places',\n", " '''\n", " width: ramp($pop_max, [0, 50])\n", " strokeWidth: 1\n", " strokeColor: opacity(white, 0.4)\n", " ''',\n", " legend={\n", " 'type': 'size-bins'\n", " }\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " CARTOframes\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", " \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", "" ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Legend: complete\n", "Map(\n", " Layer(\n", " 'SELECT * FROM populated_places WHERE adm0name = \\'Spain\\'',\n", " 'color: ramp(globalQuantiles($pop_max, 5), reverse(purpor))',\n", " legend={\n", " 'type': 'color-category',\n", " 'title': 'Population'\n", " }\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " CARTOframes\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", " \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", "" ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Map(\n", " Layer('populated_places'),\n", " default_legend=True\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.6.7" } }, "nbformat": 4, "nbformat_minor": 2 }