{ "cells": [ { "cell_type": "markdown", "id": "8e10aa18-cd11-42b0-bbdb-62ebf9b12a61", "metadata": {}, "source": [ "# Expanding Plot Limits with expandLimits()\n", "\n", "When creating visualizations, you might occasionally need to adjust your plot boundaries to encompass specific data points or values. This is where the `expandLimits()` function comes in handy. It allows you to extend the plot's scales to include particular values, ensuring they're visible in your visualization." ] }, { "cell_type": "code", "execution_count": 1, "id": "32da89cf-d22c-4cd8-be22-3574e3d4356f", "metadata": { "execution": { "iopub.execute_input": "2025-12-03T15:58:18.669910Z", "iopub.status.busy": "2025-12-03T15:58:18.668416Z", "iopub.status.idle": "2025-12-03T15:58:21.210306Z", "shell.execute_reply": "2025-12-03T15:58:21.210032Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use dataframe\n", "%use lets-plot" ] }, { "cell_type": "code", "execution_count": 2, "id": "511dfc65-66c1-481a-a8c4-ae75ff5945b0", "metadata": { "execution": { "iopub.execute_input": "2025-12-03T15:58:21.212680Z", "iopub.status.busy": "2025-12-03T15:58:21.212169Z", "iopub.status.idle": "2025-12-03T15:58:21.239048Z", "shell.execute_reply": "2025-12-03T15:58:21.239123Z" } }, "outputs": [ { "data": { "text/plain": [ "Lets-Plot Kotlin API v.4.12.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.8.1.\n", "Outputs: Web (HTML+JS), Kotlin Notebook (Swing), Static SVG (hidden)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "LetsPlot.getInfo()" ] }, { "cell_type": "code", "execution_count": 3, "id": "266d5c9a-4204-4f9c-a08f-a55a3d2e9cef", "metadata": { "execution": { "iopub.execute_input": "2025-12-03T15:58:21.240561Z", "iopub.status.busy": "2025-12-03T15:58:21.240107Z", "iopub.status.idle": "2025-12-03T15:58:21.975715Z", "shell.execute_reply": "2025-12-03T15:58:21.975842Z" } }, "outputs": [ { "data": { "application/kotlindataframe+json": "{\"nrow\":3,\"ncol\":9,\"columns\":[\"miles per gallon\",\"number of cylinders\",\"engine displacement (cu. inches)\",\"engine horsepower\",\"vehicle weight (lbs.)\",\"time to accelerate (sec.)\",\"model year\",\"origin of car\",\"vehicle name\"],\"is_formatted\":false,\"kotlin_dataframe\":[{\"miles per gallon\":18.0,\"number of cylinders\":8,\"engine displacement (cu. inches)\":307.0,\"engine horsepower\":130,\"vehicle weight (lbs.)\":3504,\"time to accelerate (sec.)\":12.0,\"model year\":70,\"origin of car\":\"US\",\"vehicle name\":\"chevrolet chevelle malibu\"},{\"miles per gallon\":15.0,\"number of cylinders\":8,\"engine displacement (cu. inches)\":350.0,\"engine horsepower\":165,\"vehicle weight (lbs.)\":3693,\"time to accelerate (sec.)\":11.5,\"model year\":70,\"origin of car\":\"US\",\"vehicle name\":\"buick skylark 320\"},{\"miles per gallon\":18.0,\"number of cylinders\":8,\"engine displacement (cu. inches)\":318.0,\"engine horsepower\":150,\"vehicle weight (lbs.)\":3436,\"time to accelerate (sec.)\":11.0,\"model year\":70,\"origin of car\":\"US\",\"vehicle name\":\"plymouth satellite\"}]}", "text/html": [ " \n", " \n", " \n", " \n", " \n", "DataFrame: rowsCount = 3, columnsCount = 9
\n", "| miles per gallon | number of cylinders | engine displacement (cu. inches) | engine horsepower | vehicle weight (lbs.) | time to accelerate (sec.) | model year | origin of car | vehicle name |
|---|---|---|---|---|---|---|---|---|
| 18.000000 | 8 | 307.000000 | 130 | 3504 | 12.000000 | 70 | US | chevrolet chevelle malibu |
| 15.000000 | 8 | 350.000000 | 165 | 3693 | 11.500000 | 70 | US | buick skylark 320 |
| 18.000000 | 8 | 318.000000 | 150 | 3436 | 11.000000 | 70 | US | plymouth satellite |