{ "cells": [ { "cell_type": "markdown", "id": "cf021754", "metadata": {}, "source": [ "# Applying Common Theme to a Plot Group\n", "\n", "You can add a **common theme** to an antire group of plots (i.e. `gggrid()`) to have \\\n", "each subplot in the group inherited this theme.\n", "\n", "Howether, a **theme** added to an individual subplot will override settings in the **common theme**." ] }, { "cell_type": "code", "execution_count": 1, "id": "ce848ad8", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "a342e22d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "8ac75c66", "metadata": {}, "outputs": [], "source": [ "# Line\n", "x = np.linspace(-4 * np.pi, 4 * np.pi, 100)\n", "line_data = {\n", " 'x': x, \n", " 'y': np.sin(x)\n", "} \n", "line = ggplot(line_data, aes(x='x', y='y')) + geom_line() + ggtitle(\"Line\")\n", "\n", "# Bars\n", "np.random.seed(37)\n", "bar_data = {'x': np.random.randint(10, size=100)}\n", "bar = ggplot(bar_data, aes(x='x')) + geom_bar() + ggtitle(\"Barchart\")\n", " \n", "# Boxplot\n", "box_data = {\n", " 'x': np.random.choice(['a', 'b', 'c'], size=100), \n", " 'y': np.random.normal(size=100)\n", "}\n", "box = ggplot(box_data, aes(x='x', y='y')) + geom_boxplot() + ggtitle(\"Boxplot\")\n", "\n", "# Pie\n", "pie_data = {\n", " 'name' : ['rock', 'paper', 'scissors'],\n", " 'slice': [1, 3, 3]\n", "}\n", "pie = ggplot(pie_data) + geom_pie(aes(fill='name', slice='slice'),\n", " stat='identity',\n", " size=0.5, size_unit=\"x\"\n", " )\n", "\n", "# Grid\n", "grid = gggrid(\n", " [line, bar, box, pie],\n", " ncol=2\n", ") + ggsize(700, 400)" ] }, { "cell_type": "markdown", "id": "aedd9918", "metadata": {}, "source": [ "#### 1. A Group without Custom Theme Settings" ] }, { "cell_type": "code", "execution_count": 4, "id": "90778ae0", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ], "text/plain": [ "