{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "imported-entrance", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "DataFrame: rowsCount = 5, columnsCount = 12
\n", " \n", " \n", " " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val mpg_df = DataFrame.readCSV(\"https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg.csv\")\n", "mpg_df.head()\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "demanding-flooring", "metadata": {}, "outputs": [], "source": [ "val p = letsPlot(mpg_df.toMap()) { x = \"cty\"; y = \"hwy\"; color = \"drv\" } + \n", " geomPoint(tooltips = layerTooltips().line(\"@manufacturer @model\"))\n", " \n", "// with facets\n", "val pf = p + facetGrid(y = \"drv\")" ] }, { "cell_type": "code", "execution_count": 5, "id": "polished-convenience", "metadata": {}, "outputs": [], "source": [ "fun themeWithFlavors(\n", " plot: org.jetbrains.letsPlot.intern.Plot, \n", " theme: org.jetbrains.letsPlot.intern.OptionsMap, \n", " themeName: String\n", "): GGBunch {\n", " val (w, h) = 400 to 300\n", " return gggrid(\n", " plots = listOf(\n", " plot + theme + ggtitle(themeName),\n", " plot + theme + ggtitle(\"flavorDarcula()\") + flavorDarcula(),\n", " plot + theme + ggtitle(\"flavorSolarizedLight()\") + flavorSolarizedLight(),\n", " plot + theme + ggtitle(\"flavorSolarizedDark()\") + flavorSolarizedDark(),\n", " plot + theme + ggtitle(\"flavorHighContrastLight()\") + flavorHighContrastLight(),\n", " plot + theme + ggtitle(\"flavorHighContrastDark()\") + flavorHighContrastDark()\n", " ),\n", " ncol = 2,\n", " cellWidth = w,\n", " cellHeight = h,\n", " fit = true\n", " )\n", "}" ] }, { "cell_type": "code", "execution_count": 6, "id": "broken-worship", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(p, themeMinimal2(), \"Minimal2\")" ] }, { "cell_type": "code", "execution_count": 7, "id": "aquatic-italy", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(pf, themeMinimal2(), \"Minimal2 + facets\")" ] }, { "cell_type": "code", "execution_count": 8, "id": "quantitative-infrastructure", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(p, themeMinimal(), \"Minimal\")" ] }, { "cell_type": "code", "execution_count": 9, "id": "prime-mortality", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(pf, themeMinimal(), \"Minimal + facets\")" ] }, { "cell_type": "code", "execution_count": 10, "id": "laughing-suite", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(p, themeClassic(), \"Classic\")" ] }, { "cell_type": "code", "execution_count": 11, "id": "motivated-giving", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(pf, themeClassic(), \"Classic+ facets\")" ] }, { "cell_type": "code", "execution_count": 12, "id": "revolutionary-boxing", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(p, themeLight(), \"Light\")" ] }, { "cell_type": "code", "execution_count": 13, "id": "medieval-passage", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(pf, themeLight(), \"Light + facets\")" ] }, { "cell_type": "code", "execution_count": 14, "id": "theoretical-genesis", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(p, themeGrey(), \"Grey\")" ] }, { "cell_type": "code", "execution_count": 15, "id": "plastic-whale", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(pf, themeGrey(), \"Grey + facets\")" ] }, { "cell_type": "code", "execution_count": 16, "id": "stone-chapel", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(p, themeNone(), \"None\")" ] }, { "cell_type": "code", "execution_count": 17, "id": "failing-concentration", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(pf, themeNone(), \"None + facets\")" ] }, { "cell_type": "code", "execution_count": 18, "id": "textile-proportion", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(p, themeBW(), \"BW\")" ] }, { "cell_type": "code", "execution_count": 19, "id": "existing-speed", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "themeWithFlavors(pf, themeBW(), \"BW + facets\")" ] } ], "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 }