{ "cells": [ { "cell_type": "markdown", "id": "7e964342-7b50-4265-a7ee-28fc54e03a76", "metadata": {}, "source": [ "# Parameter `arrow` for `geom_spoke()`\n", "\n", "Note that the lengths of the arrow heads depend on the total lengths of the arrows." ] }, { "cell_type": "code", "execution_count": 1, "id": "5a32162d-828e-4460-a164-071c20886102", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "b0d6ff7e-ea7d-4d5b-9c03-c6a61fbb1aaa", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "514279b4-8143-47a7-9795-6bbb5438b8a7", "metadata": {}, "outputs": [], "source": [ "def F(xarray, yarray):\n", " return yarray, -xarray\n", "\n", "def cartesian_to_polar(xarray, yarray):\n", " rarray = np.sqrt(xarray**2 + yarray**2)\n", " return rarray / rarray.max(), np.arctan2(yarray, xarray)" ] }, { "cell_type": "code", "execution_count": 4, "id": "c5a8950a-3845-4e6e-ac24-185ee48a8c10", "metadata": {}, "outputs": [], "source": [ "n = 11\n", "a, b = -5, 5\n", "space = np.linspace(a, b, n)\n", "X, Y = np.meshgrid(space, space)\n", "R, A = cartesian_to_polar(*F(X, Y))\n", "data = dict(x=X.reshape(-1), y=Y.reshape(-1), r=R.reshape(-1), a=A.reshape(-1))" ] }, { "cell_type": "code", "execution_count": 5, "id": "9a9609db-4fc0-41c7-91f1-0501d1c14ac1", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ], "text/plain": [ "