{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "confident-catalyst", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use lets-plot\n", "//%use krangl" ] }, { "cell_type": "code", "execution_count": 2, "id": "abandoned-twelve", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Lets-Plot Kotlin API v.4.1.1. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.2.5.1." ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "LetsPlot.getInfo() // This prevents Krangl from loading an obsolete version of Lets-Plot classes." ] }, { "cell_type": "code", "execution_count": 3, "id": "knowing-mailing", "metadata": {}, "outputs": [], "source": [ "%use krangl" ] }, { "cell_type": "code", "execution_count": 4, "id": "straight-security", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
manufacturermodeldisplyearcyltransdrvctyhwyflclass
1audia41.819994auto(l5)f1829pcompact
2audia41.819994manual(m5)f2129pcompact
3audia42.020084manual(m6)f2031pcompact

Shape: 3 x 12. \n", "

" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "var mpg = DataFrame.readCSV(\"https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg.csv\")\n", "mpg.head(3)\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "vital-amendment", "metadata": {}, "outputs": [], "source": [ "val p = letsPlot(mpg.toMap()) + theme(axisTitleX=\"blank\")" ] }, { "cell_type": "code", "execution_count": 6, "id": "exotic-diagnosis", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val boxPlot = p + \n", " geomBoxplot(color=\"#579673\", fill=\"#9AC0B3\", size=1.5) {\n", " x = asDiscrete(\"class\", order=1, orderBy=\"..middle..\")\n", " y = \"hwy\" \n", " } + \n", " ggsize(750, 300)\n", " \n", "boxPlot + ggtitle(\"Default\") " ] }, { "cell_type": "code", "execution_count": 7, "id": "touched-bicycle", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "boxPlot + ggtitle(\"Flipped\") + coordFlip()" ] }, { "cell_type": "code", "execution_count": 8, "id": "egyptian-speech", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val barPlot = p + \n", " geomBar(size=1.5, alpha=0.7, width=0.7) {\n", " x = asDiscrete(\"manufacturer\", orderBy=\"..count..\")\n", " fill = \"class\"\n", " color = \"class\"\n", " } +\n", " ggsize(800, 300)\n", " \n", "barPlot + ggtitle(\"Default\")" ] }, { "cell_type": "code", "execution_count": 9, "id": "major-royal", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "barPlot + ggtitle(\"Flipped\") + coordFlip()" ] } ], "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.7.20-dev-1299" } }, "nbformat": 4, "nbformat_minor": 5 }