{ "cells": [ { "cell_type": "markdown", "id": "9c919fd0", "metadata": {}, "source": [ "# Geodesic lines on livemap: `flat` parameter.\n", "\n", "\n", "Parameter `flat` enables or disables geodesic lines on livemap.\n", "\n", "Layers that support `flat` parameter are `geom_segment()` and `geom_path()`:\n", "\n", "- `False` (by default) - allows projection to curve a line\n", "- `True` - keeps a line flat" ] }, { "cell_type": "code", "execution_count": 1, "id": "8074593b", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:33:01.837282Z", "iopub.status.busy": "2024-04-17T07:33:01.837188Z", "iopub.status.idle": "2024-04-17T07:33:02.162050Z", "shell.execute_reply": "2024-04-17T07:33:02.161605Z" } }, "outputs": [], "source": [ "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "07854c6d", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:33:02.163640Z", "iopub.status.busy": "2024-04-17T07:33:02.163511Z", "iopub.status.idle": "2024-04-17T07:33:02.165604Z", "shell.execute_reply": "2024-04-17T07:33:02.165433Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "3a86c13e", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:33:02.166615Z", "iopub.status.busy": "2024-04-17T07:33:02.166541Z", "iopub.status.idle": "2024-04-17T07:33:02.167969Z", "shell.execute_reply": "2024-04-17T07:33:02.167792Z" }, "scrolled": true }, "outputs": [], "source": [ "data = {\n", " 'lon': [-73.7997, -149.9002],\n", " 'lat': [40.6408, 61.2180],\n", "}" ] }, { "cell_type": "markdown", "id": "22e1cb31", "metadata": {}, "source": [ "#### 1. Default Presentation\n", "\n", "By default a geodesic is drawn for `geom_path()` and `geom_segment()` on livemap. It is the shortest path between points on earth." ] }, { "cell_type": "code", "execution_count": 4, "id": "d3eacd9f", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:33:02.169005Z", "iopub.status.busy": "2024-04-17T07:33:02.168932Z", "iopub.status.idle": "2024-04-17T07:33:02.200677Z", "shell.execute_reply": "2024-04-17T07:33:02.200444Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ggplot(data, aes(x='lon', y='lat')) + \\\n", " geom_livemap() + \\\n", " geom_path()" ] }, { "cell_type": "markdown", "id": "114fdc86", "metadata": {}, "source": [ "#### 2. With flat=True\n", "\n", "If it is necessary to indicate distances for example, travel routes, a straight line is better. This is how `geom_path()` is rendered with parameter `flat=True` on livemap." ] }, { "cell_type": "code", "execution_count": 5, "id": "8b5875e5", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:33:02.201833Z", "iopub.status.busy": "2024-04-17T07:33:02.201751Z", "iopub.status.idle": "2024-04-17T07:33:02.204259Z", "shell.execute_reply": "2024-04-17T07:33:02.204088Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ggplot(data, aes(x='lon', y='lat')) + \\\n", " geom_livemap() + \\\n", " geom_path(flat=True)" ] } ], "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.10.13" } }, "nbformat": 4, "nbformat_minor": 5 }