{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "573aa8f4-e152-4397-8b2f-a6164c2e49d4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The geodata is provided by © OpenStreetMap contributors and is made available here under the Open Database License (ODbL).\n" ] }, { "data": { "text/html": [ "\n", " \n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "from lets_plot import *\n", "from lets_plot.geo_data import *\n", "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 2, "id": "3c539dba-0ceb-4dfc-905c-e43ac89f67d3", "metadata": {}, "outputs": [], "source": [ "france = geocode_countries(['France'])\n", "germany = geocode_countries(['Germany'])" ] }, { "cell_type": "markdown", "id": "e506e977-bb39-47c1-8866-d2c5c5285ad6", "metadata": {}, "source": [ "#### Simple with scale" ] }, { "cell_type": "code", "execution_count": 3, "id": "8006b809-e715-41c2-9717-9fc129fc21b4", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(ggplot() + geom_livemap() \n", " + geom_label(aes(label='found name'), nudge_y=1, map=france, color='red') \n", " + geom_text(aes(label='found name'), nudge_y=1, map=germany, color='#02633e'))" ] }, { "cell_type": "markdown", "id": "2ec00a94-4ca4-445d-bb44-7244d482bde0", "metadata": {}, "source": [ "#### Without scale" ] }, { "cell_type": "code", "execution_count": 4, "id": "4f3cc48f-c9e8-4cdc-b830-8df8162861f1", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(ggplot() + geom_livemap(const_size_zoomin=0) \n", " + geom_label(aes(label='found name'), nudge_y=1, map=france, color='red') \n", " + geom_text(aes(label='found name'), nudge_y=1, map=germany, color='#02633e'))" ] }, { "cell_type": "markdown", "id": "3d7904dc-69d9-4cd6-a55a-9f2b113bca04", "metadata": {}, "source": [ "#### One step scale" ] }, { "cell_type": "code", "execution_count": 5, "id": "ed06b2ef-18ca-47da-9d4e-a637a9269880", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(ggplot() + geom_livemap(const_size_zoomin=1) \n", " + geom_label(aes(label='found name'), nudge_y=1, map=france, color='red') \n", " + geom_text(aes(label='found name'), nudge_y=1, map=germany, color='#02633e'))" ] }, { "cell_type": "markdown", "id": "a94056fe-0497-4cdb-a466-43eb9b212e48", "metadata": {}, "source": [ "#### Empty labels" ] }, { "cell_type": "code", "execution_count": 6, "id": "b8ce940a-b6d5-4d08-8a3a-6b29f2fae07e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(ggplot() + geom_livemap() \n", " + geom_label(label='', nudge_y=1, map=france, color='red') \n", " + geom_text(label='', nudge_y=1, map=germany, color='#02633e'))" ] }, { "cell_type": "markdown", "id": "b27da21e-1744-4d4e-aa67-f60427080b36", "metadata": {}, "source": [ "#### Multiline text" ] }, { "cell_type": "code", "execution_count": 7, "id": "463055a4-d0f1-41e4-a01b-f72d69229085", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(ggplot() + geom_livemap() \n", " + geom_label(label='Exemple d\\'un \\nlong texte', nudge_y=1, map=france, color='red') \n", " + geom_text(label='Beispiel \\n eines langen \\ntextes', nudge_y=1, map=germany, color='#02633e'))" ] }, { "cell_type": "code", "execution_count": null, "id": "e01e6650-282c-4953-b714-812509f911cf", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 8, "id": "7a6ad269-50c4-463d-b775-926ce3639920", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(ggplot() + geom_livemap() \n", " + geom_label(label='Mit Neigung', angle=90, nudge_y=1, map=france, color='red') \n", " + geom_text(label='Avec inclinaison', angle=127, nudge_y=1, map=germany, color='#02633e'))" ] }, { "cell_type": "markdown", "id": "aa2435f1-4f55-418c-a06b-115de87fa555", "metadata": {}, "source": [ "#### With hjust and vjust" ] }, { "cell_type": "code", "execution_count": 9, "id": "afe0281f-7ed2-4664-abda-070c35862827", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(ggplot() + geom_livemap() \n", "+ geom_point(map=france, color='red') \n", "+ geom_label(aes(label='found name'), hjust=1, vjust=0, map=france, color='red') \n", "+ geom_point(map=germany, color='#02633e') \n", "+ geom_text(aes(label='found name'), hjust=0, vjust=1, map=germany, color='#02633e'))" ] }, { "cell_type": "code", "execution_count": null, "id": "4fc95658-9740-4856-b1c4-ff3b5d5d173a", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.20" } }, "nbformat": 4, "nbformat_minor": 5 }