{ "cells": [ { "cell_type": "markdown", "id": "cf9a1628", "metadata": {}, "source": [ "# Sharing X,Y-axis Scale Limits\n", "Use `sharex`, `sharey` parameters in the `gggrid()` function \n", "to control sharing of axis scale limits among plots in grid:\n", "\n", "- \"all\" or `True` - share limits between all subplots\n", "- \"none\" or `False` - do not share limits between subplots\n", "- \"row\" - share limits between subplots in the same row\n", "- \"col\" - share limits between subplots in the same column\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "a46ceb17", "metadata": {}, "outputs": [], "source": [ "from lets_plot import *\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "id": "40380e4b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "d45ce9e7", "metadata": {}, "outputs": [], "source": [ "np.random.seed(37)\n", "dat1 = {'x': np.random.normal(size=1000)}\n", "dat2 = {'x': np.random.normal(size=200)}\n", "\n", "p1 = ggplot(dat1, aes(x='x')) + geom_histogram()\n", "p2 = ggplot(dat2, aes(x='x')) + geom_histogram()" ] }, { "cell_type": "markdown", "id": "89d899a4", "metadata": {}, "source": [ "#### 1. Two Independent Charts in Grid" ] }, { "cell_type": "code", "execution_count": 4, "id": "48b26e36", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid([p1, p2])" ] }, { "cell_type": "markdown", "id": "51039f1e", "metadata": {}, "source": [ "#### 2. Share Scale Limits of the Y-axis" ] }, { "cell_type": "code", "execution_count": 5, "id": "95b4eb28", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid([p1, p2], sharey=True)" ] }, { "cell_type": "markdown", "id": "f24d2598", "metadata": {}, "source": [ "#### 3. Share Scale Limits of both, X and Y-axis" ] }, { "cell_type": "code", "execution_count": 6, "id": "11ca7b66", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid([p1, p2], sharex=True, sharey=True)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.18" } }, "nbformat": 4, "nbformat_minor": 5 }