{ "cells": [ { "cell_type": "markdown", "id": "american-attachment", "metadata": {}, "source": [ "# Plot Margins\n", "\n", "`plot_margin` parameter in `theme()` allows to change the margin areas of a plot using the `margin()` function." ] }, { "cell_type": "code", "execution_count": 1, "id": "announced-investigation", "metadata": { "execution": { "iopub.execute_input": "2024-04-26T12:08:40.380853Z", "iopub.status.busy": "2024-04-26T12:08:40.380853Z", "iopub.status.idle": "2024-04-26T12:08:41.370413Z", "shell.execute_reply": "2024-04-26T12:08:41.370413Z" } }, "outputs": [], "source": [ "import numpy as np\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "corporate-passion", "metadata": { "execution": { "iopub.execute_input": "2024-04-26T12:08:41.371462Z", "iopub.status.busy": "2024-04-26T12:08:41.371462Z", "iopub.status.idle": "2024-04-26T12:08:41.386306Z", "shell.execute_reply": "2024-04-26T12:08:41.386306Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "1aadd36a-0358-4edf-9ded-4b8f0ff0060a", "metadata": { "execution": { "iopub.execute_input": "2024-04-26T12:08:41.386306Z", "iopub.status.busy": "2024-04-26T12:08:41.386306Z", "iopub.status.idle": "2024-04-26T12:08:41.496845Z", "shell.execute_reply": "2024-04-26T12:08:41.496845Z" } }, "outputs": [], "source": [ "np.random.seed(42)\n", "data = {'x': np.random.randint(10, size=100)}\n", "\n", "p = ggplot(data, aes(x='x')) + geom_bar() + ggtitle(\"Bar Сhart\") + \\\n", " theme(plot_background=element_rect(size = 6))" ] }, { "cell_type": "markdown", "id": "8d2d1e77-e38d-42d1-8726-7dd0b67925ec", "metadata": {}, "source": [ "#### Plot without Margins" ] }, { "cell_type": "code", "execution_count": 4, "id": "51e28dc7-d549-42cb-bcb5-a2389b369f32", "metadata": { "execution": { "iopub.execute_input": "2024-04-26T12:08:41.496845Z", "iopub.status.busy": "2024-04-26T12:08:41.496845Z", "iopub.status.idle": "2024-04-26T12:08:41.528140Z", "shell.execute_reply": "2024-04-26T12:08:41.528140Z" } }, "outputs": [ { "data": { "text/html": [ " \n", " " ], "text/plain": [ "