{ "cells": [ { "cell_type": "markdown", "id": "50b64383-b9cb-4e20-bfec-c59d96cb0f63", "metadata": {}, "source": [ "# The `panel_inset` Parameter in `theme()`" ] }, { "cell_type": "code", "execution_count": 1, "id": "a181905e-ddbd-416e-8e10-20210d57f4bd", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from lets_plot import *\n", "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 2, "id": "bd55dece-a599-4a1e-939e-3779c4a0adfc", "metadata": {}, "outputs": [], "source": [ "hours = list(map(lambda v: '{:02d}:00'.format(v), range(12)))\n", "\n", "p = ggplot() \\\n", " + geom_point(aes(x=hours)) \\\n", " + theme_grey() \\\n", " + theme(axis_line=element_line(color='black'))" ] }, { "cell_type": "markdown", "id": "b4f60f05-f388-4fab-8bec-cb347612d009", "metadata": {}, "source": [ "## Polar Coordinate System\n", "\n", "In the polar coordinate system, it's common for tick labels to overlap.\n", "\n", "The `panel_inset` parameter assists in creating additional space to accommodate tick labels more effectively." ] }, { "cell_type": "code", "execution_count": 3, "id": "6f8f448b-6033-4e79-b730-51aa45edbc2f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid([\n", " p + coord_polar(),\n", " p + theme(panel_inset=[0, 35]) + coord_polar(),\n", " p + theme(panel_inset=[0, 35]) + coord_polar(transform_bkgr=False),\n", "])" ] }, { "cell_type": "markdown", "id": "afd30d53-4a7a-46f7-9394-233e7be0441c", "metadata": {}, "source": [ "## Rectangular Coordinate System \n", "In rectangular coordinate systems, the `panel_inset` parameter functions as a margin, adjusting the panel boundaries within the plot:" ] }, { "cell_type": "code", "execution_count": 4, "id": "75f5e483-d09c-4ab5-9431-591e5d74b7d8", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid([\n", " p,\n", " p + theme(panel_inset=15)\n", "])" ] } ], "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 }