{ "cells": [ { "cell_type": "markdown", "id": "bed2046d", "metadata": {}, "source": [ "# New Scale Transformations: `log2` and `symlog`" ] }, { "cell_type": "code", "execution_count": 1, "id": "b545b7bd", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use lets-plot" ] }, { "cell_type": "code", "execution_count": 2, "id": "23da856d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Lets-Plot Kotlin API v.4.5.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.1.0." ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "LetsPlot.getInfo()" ] }, { "cell_type": "code", "execution_count": 3, "id": "d3c457ce", "metadata": {}, "outputs": [], "source": [ "fun getData(n: Int): Map> {\n", " val x = (-n..n).map(Int::toDouble)\n", " val y = x.map {\n", " when {\n", " it == 0.0 -> it\n", " it > 0 -> exp(it)\n", " else -> -exp(-it)\n", " }\n", " }\n", " return mapOf(\"x\" to x, \"y\" to y)\n", "}" ] }, { "cell_type": "code", "execution_count": 4, "id": "4037b651", "metadata": {}, "outputs": [], "source": [ "val data = getData(10)" ] }, { "cell_type": "code", "execution_count": 5, "id": "1709c86a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val p = letsPlot(data) { x = \"x\"; y = \"y\" } + geomPoint()\n", "\n", "gggrid(\n", " listOf(\n", " p + ggtitle(\"Default\"),\n", " p + scaleYContinuous(trans=\"symlog\") + ggtitle(\"trans='symlog'\"),\n", " p + scaleYContinuous(trans=\"log10\") + ggtitle(\"trans='log10'\"),\n", " p + scaleYContinuous(trans=\"log2\") + ggtitle(\"trans='log2'\"),\n", " ), \n", " ncol=2\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.8.20" } }, "nbformat": 4, "nbformat_minor": 5 }