{ "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": "2025-11-05T13:46:55.399317Z", "iopub.status.busy": "2025-11-05T13:46:55.399224Z", "iopub.status.idle": "2025-11-05T13:46:55.402640Z", "shell.execute_reply": "2025-11-05T13:46:55.402301Z" } }, "outputs": [], "source": [ "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "07854c6d", "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:46:55.403720Z", "iopub.status.busy": "2025-11-05T13:46:55.403640Z", "iopub.status.idle": "2025-11-05T13:46:55.405291Z", "shell.execute_reply": "2025-11-05T13:46:55.405130Z" } }, "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": "2025-11-05T13:46:55.406097Z", "iopub.status.busy": "2025-11-05T13:46:55.406030Z", "iopub.status.idle": "2025-11-05T13:46:55.407308Z", "shell.execute_reply": "2025-11-05T13:46:55.407135Z" }, "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": "2025-11-05T13:46:55.408113Z", "iopub.status.busy": "2025-11-05T13:46:55.408045Z", "iopub.status.idle": "2025-11-05T13:46:55.436478Z", "shell.execute_reply": "2025-11-05T13:46:55.436287Z" } }, "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": "2025-11-05T13:46:55.437616Z", "iopub.status.busy": "2025-11-05T13:46:55.437539Z", "iopub.status.idle": "2025-11-05T13:46:55.440342Z", "shell.execute_reply": "2025-11-05T13:46:55.440168Z" } }, "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 }