{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "27c415bc-19bd-4ab4-80c9-efdb5d33c03a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "from lets_plot import *\n", "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 2, "id": "a048d094-8294-47ac-98d4-920c2c441f64", "metadata": {}, "outputs": [], "source": [ "np.random.seed(0) \n", "N = 200\n", "noise = dict(\n", " x = np.random.uniform(0, 200, N),\n", " y = np.random.uniform(100, 400, N),\n", " size = np.random.uniform(0.1, 2, N) \n", ")\n", "backdrop = geom_point(aes(\"x\", \"y\", size=\"size\"), data=noise, tooltips='none') " ] }, { "cell_type": "code", "execution_count": 3, "id": "87412abd-01b8-4295-969d-cf967fbbc5fb", "metadata": {}, "outputs": [], "source": [ "items = [\n", " dict (\n", " name = \"Lets-Plot\\nMultiplatform\",\n", " documentationUrl = \"https://lets-plot.org\",\n", " sourcesUrl = \"https://github.com/JetBrains/lets-plot\",\n", " x = 0, y = 0, size = 14, shape = 16, angle = 0\n", " ),\n", " dict (\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, y = 150, size = 9, shape = 15, angle = 15\n", " ),\n", " dict (\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, y = 200, size = 7, shape = 15, angle = -15\n", " ),\n", " dict (\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, y = 250, size = 7, shape = 15, angle = 30\n", " ),\n", " dict (\n", " name = \"Geocoding\",\n", " documentationUrl = \"https://lets-plot.org/python/pages/geocoding.html\",\n", " sourcesUrl = \"https://github.com/JetBrains/lets-plot\",\n", " x = 70, y = 320, size = 7, shape = 17, angle = 0\n", " ),\n", "]" ] }, { "cell_type": "code", "execution_count": 4, "id": "4310428d-8bd9-4b6d-982e-a0b76ea49189", "metadata": {}, "outputs": [], "source": [ "data = {\n", " \"name\": [],\n", " \"documentationUrl\": [],\n", " \"sourcesUrl\": [],\n", " \"x\": [],\n", " \"y\": [],\n", " \"size\": [],\n", " \"shape\": [],\n", " \"angle\": [],\n", "}\n", "\n", "for item in items:\n", " for key in data:\n", " data[key].append(item[key])\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "abc5e82f-06f0-4fa0-9dfb-f244e1d8e45b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(ggplot(data) + backdrop\n", " + geom_point(aes(\"x\", \"y\", size=\"size\", shape=\"shape\", angle=\"angle\", color=\"name\"), show_legend=False,\n", " tooltips=layer_tooltips()\n", " .title(\"@name\")\n", " .line(\"Links: docs, sources\")\n", " )\n", " + geom_text(x=50, y=250, size=12,\n", " label=\"Hover, then click\\nto freeze the tooltip.\\nClick links\\nto navigate.\")\n", " + geom_segment(x=70, y=250, xend=0, yend=0,\n", " size_start=150, size_end=20,\n", " arrow=arrow(type='open', angle=40)) \n", " + scale_shape_identity() + scale_size_identity()\n", " + scale_y_continuous(breaks=[150, 200, 250, 320]) \n", " + coord_polar() \n", " + ylim(0, 400) + ggsize(800, 800) \n", " + labs(\n", " title='The Observable LP-verse',\n", " subtitle='Latest news.',\n", " caption='User stories.')\n", " + theme(\n", " plot_title=element_text(size=25, face=\"bold\", hjust=0.5),\n", " plot_subtitle=element_text(hjust=0.5),\n", " plot_margin=[40, 0, 0], \n", " axis_title='blank',\n", " axis_text='blank',\n", " axis_ticks='blank',\n", " panel_grid='blank', \n", " panel_grid_major_y=element_line(size=3, linetype='dotted') \n", " )\n", " + flavor_high_contrast_dark()\n", ")\n" ] } ], "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.9.20" } }, "nbformat": 4, "nbformat_minor": 5 }