{ "cells": [ { "cell_type": "markdown", "id": "c6ba76d5-7d0e-44b6-9524-f55b2bd4aa30", "metadata": {}, "source": [ "# Collecting Guides in `gggrid()`\n", "\n", "The `guides` parameter controls how legends and colorbars are handled when arranging plots in a grid.\n", "\n", "**`guides='auto'`** (default) \n", "Keep guides in subplots by default. However, if this grid is nested inside another grid that uses `guides='collect'`, pass the guides up for collection at that higher level.\n", "\n", "**`guides='collect'`** \n", "Collect all guides (legends and colorbars) from subplots and place them alongside the grid figure, automatically removing duplicates.\n", "\n", "**`guides='keep'`** \n", "Keep guides in their original subplots. No collection occurs at this level, even if an outer grid requests collection.\n", "\n", "#### Duplicate Detection\n", "\n", "Guides are compared by their visual appearance:\n", "\n", "**For legends:** \n", "Two legends are considered duplicates if they have identical \n", "- title\n", "- labels\n", "- all aesthetic values (colors, shapes, sizes, line types, etc.)\n", "\n", "**For colorbars:** \n", "Two colorbars are considered duplicates if they have identical \n", "- title\n", "- domain limits\n", "- breaks (tick positions)\n", "- color gradient\n", "\n", "Note: Colorbars from different data ranges typically have different limits and will not merge without manual harmonization." ] }, { "cell_type": "code", "execution_count": 1, "id": "945e991b-fb1f-4085-ae55-bad8302ad79a", "metadata": {}, "outputs": [], "source": [ "from lets_plot import *\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "id": "157872ee-59fa-4f4d-b8a9-61cbae831485", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "a7b44990-4707-4880-b1f6-6b24c8ca8b94", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(53940, 10)\n", "(1000, 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.24 | \n", "Ideal | \n", "G | \n", "VVS1 | \n", "62.1 | \n", "56.0 | \n", "559 | \n", "3.97 | \n", "4.00 | \n", "2.47 | \n", "
| 1 | \n", "0.58 | \n", "Very Good | \n", "F | \n", "VVS2 | \n", "60.0 | \n", "57.0 | \n", "2201 | \n", "5.44 | \n", "5.42 | \n", "3.26 | \n", "
| 2 | \n", "0.40 | \n", "Ideal | \n", "E | \n", "VVS2 | \n", "62.1 | \n", "55.0 | \n", "1238 | \n", "4.76 | \n", "4.74 | \n", "2.95 | \n", "
| 3 | \n", "0.43 | \n", "Premium | \n", "E | \n", "VVS2 | \n", "60.8 | \n", "57.0 | \n", "1304 | \n", "4.92 | \n", "4.89 | \n", "2.98 | \n", "
| 4 | \n", "1.55 | \n", "Ideal | \n", "E | \n", "SI2 | \n", "62.3 | \n", "55.0 | \n", "6901 | \n", "7.44 | \n", "7.37 | \n", "4.61 | \n", "