{ "cells": [ { "cell_type": "markdown", "id": "b0b00c5e-dcef-4bba-a7b8-92ca3320063b", "metadata": {}, "source": [ "# `Zoom` and `Pan` Interactivity\n", "\n", "Use the `ggtb()` function to enable `Pan` and `Zoom` interactivity on a chart.\n", "\n", "This function adds a toolbar containing three tool-buttons: pan, rubber-band zoom, and center-point zoom. \n", "\n", "Each tool uses **mouse-drag** for its specific functionality. Additionally, the **mouse wheel** can be used for zooming in and out, regardless of the selected tool.\n", "\n", "The behavior of these tools adapts to the initial mouse drag direction:\n", "- Near-horizontal drag: restricts panning to horizontal movement or creates a vertical band for zooming.\n", "- Near-vertical drag: limits panning to vertical movement or produces a horizontal band for zooming.\n", "- Diagonal drag: allows panning in any direction or creates a rectangular area for zooming.\n", "\n", "**Double-clicking** anywhere on the plot resets it to its original coordinates, regardless of whether a tool is selected or not.\n", "\n", "Click the 4th button, `Reset`, to reset the plot and tools to their original state.\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "c805f48f-bd4a-47ce-b687-db299e29132d", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "b846c5b9-5f3d-46a6-95f2-849c6ffd18cf", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "113c62dd-177c-4090-b305-6ac953e34dd8", "metadata": {}, "outputs": [ { "data": { "text/html": [ "| \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", "