{ "cells": [ { "cell_type": "markdown", "id": "f71a43d0-3cf1-4d53-a867-cd57b1fcba30", "metadata": {}, "source": [ "# The `plotInset` Parameter in `theme()`\n", "\n", "The `plotInset` parameter in `theme()` specifies the inset for a plotting area, including the axes with their labels, but without titles.\n", "The parameter is set according to the margin rules: accept a number or a list of numbers." ] }, { "cell_type": "code", "execution_count": 1, "id": "8ae5e345-9df2-4151-82aa-c9f211083209", "metadata": { "execution": { "iopub.execute_input": "2024-08-23T10:51:57.876424Z", "iopub.status.busy": "2024-08-23T10:51:57.875106Z", "iopub.status.idle": "2024-08-23T10:52:00.028676Z", "shell.execute_reply": "2024-08-23T10:52:00.028404Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use lets-plot" ] }, { "cell_type": "code", "execution_count": 2, "id": "d4fc6a1e-fef7-446a-a3e6-ceca45c2d598", "metadata": { "execution": { "iopub.execute_input": "2024-08-23T10:52:00.030579Z", "iopub.status.busy": "2024-08-23T10:52:00.030334Z", "iopub.status.idle": "2024-08-23T10:52:00.063307Z", "shell.execute_reply": "2024-08-23T10:52:00.063480Z" } }, "outputs": [ { "data": { "text/plain": [ "Lets-Plot Kotlin API v.4.8.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.4.1." ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "LetsPlot.getInfo()" ] }, { "cell_type": "code", "execution_count": 3, "id": "1b0cc229-fd1c-43f8-83b2-9f033828ff64", "metadata": { "execution": { "iopub.execute_input": "2024-08-23T10:52:00.065032Z", "iopub.status.busy": "2024-08-23T10:52:00.064790Z", "iopub.status.idle": "2024-08-23T10:52:00.271773Z", "shell.execute_reply": "2024-08-23T10:52:00.271458Z" } }, "outputs": [], "source": [ "val start = -Math.PI\n", "val stop = Math.PI\n", "val num = 100\n", "val step = ((stop - start) / (num - 1))\n", "val x = List(num) { start + it * step }\n", "val data = mapOf(\n", " \"x\" to x,\n", " \"y\" to x.map{Math.sin(it)}\n", ") \n", "\n", "val p = letsPlot(data) { x = \"x\"; y = \"y\" } +\n", " geomLine() +\n", " ggtitle(\"Sine wave\") +\n", " themeLight() +\n", " theme(plotBackground = elementRect(size = 1))" ] }, { "cell_type": "code", "execution_count": 4, "id": "b460a64b-c905-4bcf-ac93-7b4c313729bc", "metadata": { "execution": { "iopub.execute_input": "2024-08-23T10:52:00.273423Z", "iopub.status.busy": "2024-08-23T10:52:00.272966Z", "iopub.status.idle": "2024-08-23T10:52:00.442377Z", "shell.execute_reply": "2024-08-23T10:52:00.442553Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid(listOf(\n", " p,\n", " p + theme(plotInset = 20)\n", "))" ] }, { "cell_type": "code", "execution_count": 5, "id": "d087539c-0a48-4607-851f-5f9812eae9f8", "metadata": { "execution": { "iopub.execute_input": "2024-08-23T10:52:00.444197Z", "iopub.status.busy": "2024-08-23T10:52:00.443954Z", "iopub.status.idle": "2024-08-23T10:52:00.514060Z", "shell.execute_reply": "2024-08-23T10:52:00.514235Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid(listOf(\n", " p + theme(axis = elementBlank()),\n", " p + theme(axis = elementBlank()) + theme(plotInset = listOf(0, 30))\n", "))" ] } ], "metadata": { "kernelspec": { "display_name": "Kotlin", "language": "kotlin", "name": "kotlin" }, "language_info": { "codemirror_mode": "text/x-kotlin", "file_extension": ".kt", "mimetype": "text/x-kotlin", "name": "kotlin", "nbconvert_exporter": "", "pygments_lexer": "kotlin", "version": "1.9.23" } }, "nbformat": 4, "nbformat_minor": 5 }