{ "cells": [ { "cell_type": "markdown", "id": "moving-ownership", "metadata": {}, "source": [ "# Margins\n", "\n", " \n", "The margins around the plot and text elements are controlled by the `plot_margin` parameter in `theme()` and the `margin` parameter in `element_text()` respectively.\n", "\n", "Now the parameters `plot_margin` and `margin` accept a number or a list of numbers.\n", "\n", "- A number or list of one number is specified: the same margin it applied to **all four sides**.\n", "- A list of two numbers: the first margin applies to the **top and bottom**, the second - to the **left and right**.\n", "- A list of three numbers: the first margin applies to the **top**, the second - to the **right and left**, the third - to the **bottom**.\n", "- A list of four numbers: the margins are applied to the **top, right, bottom and left** in that order.\n", "\n", "It is acceptable to use None for any side; in this case, the default side value for this element will be used." ] }, { "cell_type": "code", "execution_count": 1, "id": "liable-jacksonville", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "fiscal-rates", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "indie-yeast", "metadata": {}, "outputs": [], "source": [ "np.random.seed(42)\n", "data = {'x': np.random.randint(10, size=100)}\n", "\n", "p = ggplot(data, aes(x='x')) + \\\n", " geom_bar() + \\\n", " ggtitle(\"Bar Сhart\") + \\\n", " theme_light() + \\\n", " theme(plot_background=element_rect(size = 4))" ] }, { "cell_type": "markdown", "id": "cooked-sender", "metadata": {}, "source": [ "#### Plot without Margins" ] }, { "cell_type": "code", "execution_count": 4, "id": "buried-birth", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ], "text/plain": [ "