{ "cells": [ { "cell_type": "markdown", "id": "667912ba", "metadata": {}, "source": [ "# Limiting Labels Length for Axis and Legends\n", "\n", "Use the `lablim` parameter in `scaleXxx()` functions to specify the maximum length (number of characters) of labels for correspondent axis or legend.\n", "\n", "Labels exceeding the specified maximum lenfth will be trimmed." ] }, { "cell_type": "code", "execution_count": 1, "id": "71955ca7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use lets-plot" ] }, { "cell_type": "code", "execution_count": 2, "id": "37bf065c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Lets-Plot Kotlin API v.4.6.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.2.0." ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "LetsPlot.getInfo()" ] }, { "cell_type": "markdown", "id": "af123880", "metadata": {}, "source": [ "#### 1. Long Labels without Trimming" ] }, { "cell_type": "code", "execution_count": 3, "id": "74d9efb4", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val data = mapOf(\n", " \"x\" to listOf(\"A picture is worth a thousand words\", \"Make a long story short\")\n", ")\n", "\n", "val p = letsPlot(data) { x = \"x\"; color = \"x\" } + geomPoint(size = 7)\n", "p" ] }, { "cell_type": "markdown", "id": "a71965ae", "metadata": {}, "source": [ "#### 2. Use `lablim` Parameter to Trim X-Axis Labels" ] }, { "cell_type": "code", "execution_count": 4, "id": "4fb52193", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p + scaleXDiscrete(lablim = 10)" ] } ], "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.8.20" } }, "nbformat": 4, "nbformat_minor": 5 }