{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "e6b4a6a7-d2d9-4ab4-a53f-ee03151420d3", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:42:07.096561Z", "iopub.status.busy": "2024-11-01T20:42:07.094168Z", "iopub.status.idle": "2024-11-01T20:42:09.172549Z", "shell.execute_reply": "2024-11-01T20:42:09.172279Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use lets-plot" ] }, { "cell_type": "code", "execution_count": 2, "id": "441da677-ca63-49fc-88c1-5c932e2166eb", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:42:09.174523Z", "iopub.status.busy": "2024-11-01T20:42:09.174322Z", "iopub.status.idle": "2024-11-01T20:42:09.192548Z", "shell.execute_reply": "2024-11-01T20:42:09.192326Z" } }, "outputs": [], "source": [ "import kotlin.random.Random" ] }, { "cell_type": "code", "execution_count": 3, "id": "eccc91d8-947f-4198-bd43-93908ace27ee", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:42:09.194477Z", "iopub.status.busy": "2024-11-01T20:42:09.194265Z", "iopub.status.idle": "2024-11-01T20:42:09.348094Z", "shell.execute_reply": "2024-11-01T20:42:09.347888Z" } }, "outputs": [], "source": [ "val random = Random(seed = 42)\n", "val n = 200\n", "val noiseData = mapOf(\n", " \"x\" to List(n) { random.nextDouble(0.0, 200.0) },\n", " \"y\" to List(n) { random.nextDouble(100.0, 400.0) },\n", " \"size\" to List(n) { random.nextDouble(0.1, 2.0) }\n", ")\n", "val backdrop = geomPoint(data = noiseData, tooltips = tooltipsNone) { x = \"x\"; y = \"y\"; size = \"size\" }" ] }, { "cell_type": "code", "execution_count": 4, "id": "86477398-8e04-4bc6-855a-9ffc82b1f406", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:42:09.350157Z", "iopub.status.busy": "2024-11-01T20:42:09.349947Z", "iopub.status.idle": "2024-11-01T20:42:09.673387Z", "shell.execute_reply": "2024-11-01T20:42:09.673169Z" } }, "outputs": [], "source": [ "data class Item(\n", " val name: String,\n", " val documentationUrl: String,\n", " val sourcesUrl: String,\n", " val x: Double,\n", " val y: Double,\n", " val size: Double,\n", " val shape: Int,\n", " val angle: Double\n", ")\n", "\n", "val items = listOf(\n", " Item(\n", " name = \"Lets-Plot\\nMultiplatform\",\n", " documentationUrl = \"https://lets-plot.org\",\n", " sourcesUrl = \"https://github.com/JetBrains/lets-plot\",\n", " x = 0.0, y = 0.0, size = 14.0, shape = 16, angle = 0.0\n", " ),\n", " Item(\n", " name = \"Lets-Plot\\nfor Python\",\n", " documentationUrl = \"https://lets-plot.org/kotlin/get-started.html\",\n", " sourcesUrl = \"https://github.com/JetBrains/lets-plot-kotlin\",\n", " x = 130.0, y = 150.0, size = 9.0, shape = 15, angle = 15.0\n", " ),\n", " Item(\n", " name = \"Lets-Plot\\nfor Kotlin\",\n", " documentationUrl = \"https://lets-plot.org/kotlin/get-started.html\",\n", " sourcesUrl = \"https://github.com/JetBrains/lets-plot-kotlin\",\n", " x = 200.0, y = 200.0, size = 9.0, shape = 15, angle = -15.0\n", " ),\n", " Item(\n", " name = \"Lets-Plot\\nCompose Multiplatform\",\n", " documentationUrl = \"https://github.com/JetBrains/lets-plot-skia\",\n", " sourcesUrl = \"https://github.com/JetBrains/lets-plot-skia\",\n", " x = 80.0, y = 250.0, size = 7.0, shape = 15, angle = 30.0\n", " ),\n", " Item(\n", " name = \"Geocoding\",\n", " documentationUrl = \"https://lets-plot.org/python/pages/geocoding.html\",\n", " sourcesUrl = \"https://github.com/JetBrains/lets-plot\",\n", " x = 70.0, y = 320.0, size = 7.0, shape = 17, angle = 0.0\n", " ),\n", " Item(\n", " name = \"Kandy\",\n", " documentationUrl = \"https://kotlin.github.io/kandy/welcome.html\",\n", " sourcesUrl = \"https://github.com/Kotlin/kandy\",\n", " x = 195.0, y = 150.0, size = 4.0, shape = 16, angle = 0.0\n", " ),\n", ")\n", "\n", "val itemsData = mapOf(\n", " \"name\" to items.map(Item::name),\n", " \"documentationUrl\" to items.map(Item::documentationUrl),\n", " \"sourcesUrl\" to items.map(Item::sourcesUrl),\n", " \"x\" to items.map(Item::x),\n", " \"y\" to items.map(Item::y),\n", " \"size\" to items.map(Item::size),\n", " \"shape\" to items.map(Item::shape),\n", " \"angle\" to items.map(Item::angle),\n", ")" ] }, { "cell_type": "code", "execution_count": 5, "id": "ed5f1c78-1005-4ffd-8666-9f252c5177c6", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:42:09.675358Z", "iopub.status.busy": "2024-11-01T20:42:09.675150Z", "iopub.status.idle": "2024-11-01T20:42:09.906682Z", "shell.execute_reply": "2024-11-01T20:42:09.906515Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "letsPlot(itemsData) + backdrop +\n", " geomPoint(showLegend = false,\n", " tooltips = layerTooltips()\n", " .title(\"@name\")\n", " .line(\"Links: docs, sources\")\n", " ) { x = \"x\"; y = \"y\"; size = \"size\"; shape = \"shape\"; angle = \"angle\"; color = \"name\" } +\n", " // Kandy orbit\n", " geomPoint(x = 200, y = 200, size = 37, shape = 1, stroke = 0.07) +\n", " // Kandy stick\n", " geomSpoke(x = 195, y = 150, angle=-3.14/2/1.05, radius=30, size = 1, color = \"rgb(255,255,97)\") +\n", " // Guide\n", " geomText(x = 50, y = 250, size = 12,\n", " label = \"Hover, then click\\nto freeze the tooltip.\\nClick links\\nto navigate.\") +\n", " geomSegment(x = 70, y = 250, xend = 0, yend = 0,\n", " sizeStart = 150, sizeEnd = 20,\n", " arrow = arrow(type = \"open\", angle = 40)) +\n", " scaleYContinuous(breaks = listOf(150, 200, 250, 320)) +\n", " scaleShapeIdentity() + scaleSizeIdentity() +\n", " coordPolar() +\n", " ylim(listOf(0, 400)) +\n", " labs(title = \"The Observable LP-verse\",\n", " subtitle = \"Latest news.\",\n", " caption = \"User stories.\") +\n", " ggsize(800, 800) +\n", " theme(\n", " plotTitle = elementText(size = 25, face = \"bold\", hjust = 0.5),\n", " plotSubtitle = elementText(hjust = 0.5),\n", " plotMargin = listOf(40, 0, 0),\n", " axisTitle = \"blank\",\n", " axisText = \"blank\",\n", " axisTicks = \"blank\",\n", " panelGrid = \"blank\",\n", " panelGridMajorY = elementLine(size = 3, linetype = \"dotted\")\n", " ) +\n", " flavorHighContrastDark()" ] } ], "metadata": { "kernelspec": { "display_name": "Kotlin", "language": "kotlin", "name": "kotlin" }, "language_info": { "codemirror_mode": "text/x-kotlin", "file_extension": ".kt", "mimetype": "text/x-kotlin", "name": "kotlin", "nbconvert_exporter": "", "pygments_lexer": "kotlin", "version": "1.9.23" } }, "nbformat": 4, "nbformat_minor": 5 }