{ "cells": [ { "cell_type": "markdown", "id": "f21925d1-86ce-477c-a69c-e48d6835972b", "metadata": {}, "source": [ "## Marker Rotation\n", "\n", "Specify marker rotation (in degrees) using the `angle` aesthetic." ] }, { "cell_type": "code", "execution_count": 1, "id": "7f7b5b9d-9ae5-4518-8a0f-55d00deb040f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use lets-plot" ] }, { "cell_type": "code", "execution_count": 2, "id": "1a27a1e0-a76e-4c29-9506-aadf5ec766f0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Lets-Plot Kotlin API v.4.7.3-SNAPSHOT. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.3.3." ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "LetsPlot.getInfo()" ] }, { "cell_type": "code", "execution_count": 3, "id": "233d263e-ea61-4220-b4a7-1d7dfe24bff6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val data = mapOf(\n", " \"x\" to listOf(1, 2, 3, 4),\n", " \"a\" to listOf(0, 90, 180, 270),\n", " \"c\" to listOf(\"a\", \"b\", \"c\", \"o\")\n", ")\n", "letsPlot(data) + geomPoint(shape = 14, size = 10) { x = \"x\"; angle = \"a\" }" ] }, { "cell_type": "markdown", "id": "a5b47a33-9d9c-4bb3-8d2a-c69d3e114a96", "metadata": {}, "source": [ "#### Boxplot outlier rotation" ] }, { "cell_type": "code", "execution_count": 7, "id": "a908637c-e1c9-4a70-9188-801550f9ec95", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import kotlin.random.Random\n", "\n", "fun getRandomList(n: Int, random: Random): MutableList =\n", " MutableList(n) { random.nextDouble() }\n", " \n", "val rnd = Random(42)\n", "val n = 10000\n", "val yA = getRandomList(n, rnd)\n", "val yB = getRandomList(n, rnd)\n", "\n", "// add outlier\n", "yA[yA.lastIndex] = 1.5\n", "yB[yB.lastIndex] = 1.55\n", "\n", "val randomBoxData = mapOf(\n", " \"x\" to (List(n) { \"A\" } + List(n) { \"B\" }),\n", " \"y\" to (yA + yB),\n", ")\n", "\n", "letsPlot(randomBoxData) + geomBoxplot(shape=14, outlierSize=2, outlierAngle=90) { \n", " x = \"x\"\n", " y = \"y\"\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 }