{ "cells": [ { "cell_type": "markdown", "id": "45f8a36c-66e4-4ad7-b2ea-a77d176271f4", "metadata": {}, "source": [ "# Creating Magnifier Inset Effect with `ggbunch()`\n", "The `ggbunch()` here combines two plots into a single figure with custom layout - a main scatter plot showing diamond price vs. carat weight colored by cut quality, and a zoomed-in inset that magnifies a specific region of interest." ] }, { "cell_type": "code", "execution_count": 1, "id": "45afd3bd-ca54-426b-9821-73349442dced", "metadata": { "execution": { "iopub.execute_input": "2025-07-17T17:09:06.417847Z", "iopub.status.busy": "2025-07-17T17:09:06.417766Z", "iopub.status.idle": "2025-07-17T17:09:06.420664Z", "shell.execute_reply": "2025-07-17T17:09:06.420378Z" } }, "outputs": [], "source": [ "import pandas as pd\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "3d1a30bf-a3b1-4e54-980d-e61548b55393", "metadata": { "execution": { "iopub.execute_input": "2025-07-17T17:09:06.421820Z", "iopub.status.busy": "2025-07-17T17:09:06.421485Z", "iopub.status.idle": "2025-07-17T17:09:06.423598Z", "shell.execute_reply": "2025-07-17T17:09:06.423420Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "f9ebe179-2678-4fa3-b55a-822489e3601b", "metadata": { "execution": { "iopub.execute_input": "2025-07-17T17:09:06.424382Z", "iopub.status.busy": "2025-07-17T17:09:06.424271Z", "iopub.status.idle": "2025-07-17T17:09:07.866749Z", "shell.execute_reply": "2025-07-17T17:09:07.866423Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(53940, 10)\n" ] }, { "data": { "text/html": [ "\n", " | carat | \n", "cut | \n", "color | \n", "clarity | \n", "depth | \n", "table | \n", "price | \n", "x | \n", "y | \n", "z | \n", "
---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0.23 | \n", "Ideal | \n", "E | \n", "SI2 | \n", "61.5 | \n", "55.0 | \n", "326 | \n", "3.95 | \n", "3.98 | \n", "2.43 | \n", "
1 | \n", "0.21 | \n", "Premium | \n", "E | \n", "SI1 | \n", "59.8 | \n", "61.0 | \n", "326 | \n", "3.89 | \n", "3.84 | \n", "2.31 | \n", "
2 | \n", "0.23 | \n", "Good | \n", "E | \n", "VS1 | \n", "56.9 | \n", "65.0 | \n", "327 | \n", "4.05 | \n", "4.07 | \n", "2.31 | \n", "