{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "facial-stations", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use lets-plot\n", "%use dataframe" ] }, { "cell_type": "code", "execution_count": 2, "id": "structured-hampton", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Lets-Plot Kotlin API v.4.4.2. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.0.0." ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "LetsPlot.getInfo()" ] }, { "cell_type": "code", "execution_count": 3, "id": "automated-result", "metadata": {}, "outputs": [ { "data": { "application/kotlindataframe+json": "{\"nrow\":3,\"ncol\":12,\"columns\":[\"untitled\",\"manufacturer\",\"model\",\"displ\",\"year\",\"cyl\",\"trans\",\"drv\",\"cty\",\"hwy\",\"fl\",\"class\"],\"kotlin_dataframe\":[{\"untitled\":1,\"manufacturer\":\"audi\",\"model\":\"a4\",\"displ\":1.8,\"year\":1999,\"cyl\":4,\"trans\":\"auto(l5)\",\"drv\":\"f\",\"cty\":18,\"hwy\":29,\"fl\":\"p\",\"class\":\"compact\"},{\"untitled\":2,\"manufacturer\":\"audi\",\"model\":\"a4\",\"displ\":1.8,\"year\":1999,\"cyl\":4,\"trans\":\"manual(m5)\",\"drv\":\"f\",\"cty\":21,\"hwy\":29,\"fl\":\"p\",\"class\":\"compact\"},{\"untitled\":3,\"manufacturer\":\"audi\",\"model\":\"a4\",\"displ\":2.0,\"year\":2008,\"cyl\":4,\"trans\":\"manual(m6)\",\"drv\":\"f\",\"cty\":20,\"hwy\":31,\"fl\":\"p\",\"class\":\"compact\"}]}", "text/html": [ " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "\n", "

DataFrame: rowsCount = 3, columnsCount = 12

\n", " \n", " \n", " " ] }, "execution_count": 3, "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)" ] }, { "cell_type": "code", "execution_count": 4, "id": "russian-federation", "metadata": {}, "outputs": [], "source": [ "val p = ggplot(df.toMap()) + geomPoint {x = \"cty\"; y = \"hwy\"}" ] }, { "cell_type": "code", "execution_count": 5, "id": "nominated-rwanda", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 5, "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": 6, "id": "dominant-metallic", "metadata": {}, "outputs": [], "source": [ "val pf = p + facetGrid(x = \"drv\")" ] }, { "cell_type": "code", "execution_count": 7, "id": "spiritual-scholar", "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 7, "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.8.20" } }, "nbformat": 4, "nbformat_minor": 5 }