{ "cells": [ { "cell_type": "markdown", "id": "bbf78031", "metadata": {}, "source": [ "# Lollipop Plot\n", "\n", "A lollipop plot displays each element of a dataset as a segment and a circle. It is usually combined with the `count` stat, and is especially useful when you have several bars of the same height." ] }, { "cell_type": "code", "execution_count": 1, "id": "4e5f30b9", "metadata": { "execution": { "iopub.execute_input": "2026-01-27T17:06:13.899236Z", "iopub.status.busy": "2026-01-27T17:06:13.899161Z", "iopub.status.idle": "2026-01-27T17:06:13.902045Z", "shell.execute_reply": "2026-01-27T17:06:13.901710Z" } }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "aca5e584", "metadata": { "execution": { "iopub.execute_input": "2026-01-27T17:06:13.902877Z", "iopub.status.busy": "2026-01-27T17:06:13.902802Z", "iopub.status.idle": "2026-01-27T17:06:13.904613Z", "shell.execute_reply": "2026-01-27T17:06:13.904357Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "1a13082d", "metadata": { "execution": { "iopub.execute_input": "2026-01-27T17:06:13.905602Z", "iopub.status.busy": "2026-01-27T17:06:13.905533Z", "iopub.status.idle": "2026-01-27T17:06:13.907384Z", "shell.execute_reply": "2026-01-27T17:06:13.907108Z" } }, "outputs": [], "source": [ "def get_lollipop_data(size, seed=42):\n", " np.random.seed(seed)\n", " return {\n", " \"x\": [v - 15 for v in range(size)],\n", " \"y\": np.random.uniform(1, 5, size=size),\n", " \"sugar\": [v + 150 for v in range(size)]\n", " }\n", "\n", "data = get_lollipop_data(30)" ] }, { "cell_type": "code", "execution_count": 4, "id": "fd78698e", "metadata": { "execution": { "iopub.execute_input": "2026-01-27T17:06:13.908454Z", "iopub.status.busy": "2026-01-27T17:06:13.908384Z", "iopub.status.idle": "2026-01-27T17:06:13.947606Z", "shell.execute_reply": "2026-01-27T17:06:13.947186Z" } }, "outputs": [ { "data": { "text/html": [ " \n", " " ], "text/plain": [ "| \n", " | Unnamed: 0 | \n", "manufacturer | \n", "model | \n", "displ | \n", "year | \n", "cyl | \n", "trans | \n", "drv | \n", "cty | \n", "hwy | \n", "fl | \n", "class | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "1 | \n", "audi | \n", "a4 | \n", "1.8 | \n", "1999 | \n", "4 | \n", "auto(l5) | \n", "f | \n", "18 | \n", "29 | \n", "p | \n", "compact | \n", "
| 1 | \n", "2 | \n", "audi | \n", "a4 | \n", "1.8 | \n", "1999 | \n", "4 | \n", "manual(m5) | \n", "f | \n", "21 | \n", "29 | \n", "p | \n", "compact | \n", "
| 2 | \n", "3 | \n", "audi | \n", "a4 | \n", "2.0 | \n", "2008 | \n", "4 | \n", "manual(m6) | \n", "f | \n", "20 | \n", "31 | \n", "p | \n", "compact | \n", "
| 3 | \n", "4 | \n", "audi | \n", "a4 | \n", "2.0 | \n", "2008 | \n", "4 | \n", "auto(av) | \n", "f | \n", "21 | \n", "30 | \n", "p | \n", "compact | \n", "
| 4 | \n", "5 | \n", "audi | \n", "a4 | \n", "2.8 | \n", "1999 | \n", "6 | \n", "auto(l5) | \n", "f | \n", "16 | \n", "26 | \n", "p | \n", "compact | \n", "