{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "facial-stations", "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": "structured-hampton", "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() // Work around Krangl loading old Lets-Plot classes." ] }, { "cell_type": "code", "execution_count": 3, "id": "vocal-alias", "metadata": {}, "outputs": [], "source": [ "%use krangl" ] }, { "cell_type": "code", "execution_count": 4, "id": "automated-result", "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 df = DataFrame.readCSV(\"https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg.csv\")\n", "df.head(3)\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "russian-federation", "metadata": {}, "outputs": [], "source": [ "val p = ggplot(df.toMap()) + geomPoint {x = \"cty\"; y = \"hwy\"}" ] }, { "cell_type": "code", "execution_count": 6, "id": "nominated-rwanda", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid(\n", " plots = listOf(\n", " p + ggtitle(\"themeMinimal2() - the default\"),\n", " p + ggtitle(\"themeGrey()\") + themeGrey(),\n", " p + ggtitle(\"themeBW()\") + themeBW(),\n", " p + ggtitle(\"themeLight()\") + themeLight(),\n", " p + ggtitle(\"themeClassic()\") + themeClassic(),\n", " p + ggtitle(\"themeMinimal()\") + themeMinimal(),\n", " ),\n", " ncol = 2,\n", " cellWidth = 400,\n", " cellHeight = 300,\n", " vGap = 0,\n", " fit = true\n", ")" ] }, { "cell_type": "markdown", "id": "foreign-sessions", "metadata": {}, "source": [ "### Demo with facets" ] }, { "cell_type": "code", "execution_count": 7, "id": "dominant-metallic", "metadata": {}, "outputs": [], "source": [ "val pf = p + facetGrid(x = \"drv\")" ] }, { "cell_type": "code", "execution_count": 8, "id": "spiritual-scholar", "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid(\n", " plots = listOf(\n", " pf + ggtitle(\"themeMinimal2() - the default\"),\n", " pf + ggtitle(\"themeGrey()\") + themeGrey(),\n", " pf + ggtitle(\"themeBW()\") + themeBW(),\n", " pf + ggtitle(\"themeLight()\") + themeLight(),\n", " pf + ggtitle(\"themeClassic()\") + themeClassic(),\n", " pf + ggtitle(\"themeMinimal()\") + themeMinimal(),\n", " ),\n", " ncol = 1,\n", " cellWidth = 700,\n", " cellHeight = 200,\n", " vGap = 0, \n", " fit = true\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.7.20-dev-1299" } }, "nbformat": 4, "nbformat_minor": 5 }