{ "cells": [ { "cell_type": "markdown", "id": "71ae9054", "metadata": {}, "source": [ "# `geom_spoke()` As a Layer of `geom_livemap()`" ] }, { "cell_type": "code", "execution_count": 1, "id": "52aa8a3e", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "daf9e052", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "d3b828e2", "metadata": {}, "outputs": [], "source": [ "X, Y = np.meshgrid([10, 20, 30, 40], [10, 20, 30, 40])\n", "\n", "angle = np.pi / 180 * np.array([[0, 0, 5, 20],\n", " [5, 10, 20, 50],\n", " [35, 50, 65, 75],\n", " [25, 30, 50, 80]])\n", "amplitude = np.array([[1.5, 2.0, 2.5, 5.0],\n", " [2.0, 2.5, 3.0, 6.0],\n", " [2.5, 3.6, 5.0, 7.0],\n", " [3.0, 4.5, 5.0, 5.0]])\n", "data = dict(x=X.reshape(-1), y=Y.reshape(-1), amplitude=amplitude.reshape(-1), angle=angle.reshape(-1))" ] }, { "cell_type": "code", "execution_count": 4, "id": "e76870c5", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ggplot(data, aes('x', 'y', color='amplitude')) + \\\n", " geom_livemap() + \\\n", " geom_point(size=4) + \\\n", " scale_color_gradient(low='#2c7bb6', high='#d7191c') + \\\n", " geom_spoke(aes(angle='angle', radius='amplitude'), pivot='tip', size=2)" ] } ], "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.8.19" } }, "nbformat": 4, "nbformat_minor": 5 }