{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2025-03-21T16:01:51.799474Z", "iopub.status.busy": "2025-03-21T16:01:51.797523Z", "iopub.status.idle": "2025-03-21T16:01:53.637278Z", "shell.execute_reply": "2025-03-21T16:01:53.637014Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use lets-plot" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2025-03-21T16:01:53.638959Z", "iopub.status.busy": "2025-03-21T16:01:53.638682Z", "iopub.status.idle": "2025-03-21T16:01:53.684413Z", "shell.execute_reply": "2025-03-21T16:01:53.684075Z" } }, "outputs": [ { "data": { "text/plain": [ "Lets-Plot Kotlin API v.4.10.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.6.1." ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "LetsPlot.getInfo()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2025-03-21T16:01:53.686463Z", "iopub.status.busy": "2025-03-21T16:01:53.686127Z", "iopub.status.idle": "2025-03-21T16:01:54.154621Z", "shell.execute_reply": "2025-03-21T16:01:54.154699Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/plot+json": { "apply_color_scheme": true, "output": { "data": { "cond": [ "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B" ], "rating": [ 1.7687943677666822, 0.10628211826095219, 1.7204367528361415, -0.037534100873246996, -0.7556292895100587, -0.9951161662703086, 1.052027068066767, -0.6497562324361997, -0.47969604178646064, 1.3195412359422278, 0.6471885375454148, -0.6145630713451975, 0.21099118887163767, 0.83061591557465, 0.4890950549463388, 1.3037914453654387, 0.9791647128033308, -1.304372469120525, -0.6739853262611326, -0.6302272555314844, -0.06567293517548581, 0.16992439572141083, 0.4985272158114654, 0.3744336799283743, 0.8193988829709237, 2.429780509168998, 0.35327583135456675, 0.34645985018170156, 0.564510581840672, 1.1079917758816, -2.20104878328904, 1.9695418127098692, -0.2364138746138622, -0.9260104971066431, -0.23550283017719809, -0.01921041177944297, -0.8623579647574651, -0.04184743225913421, -0.34086213093508905, 0.6989387291958685, -0.21280602574129706, -1.5229462883897182, -1.114669649931767, -0.7246596018824761, -0.9795078835494803, 0.43048299121850986, 0.5860946664293265, 0.411783051565248, 2.439598419520245, -0.30589367627540626, -0.03625210379296746, -0.01523713036011583, 0.6748592497714744, 0.449083044780863, 0.7510927431339195, -0.209489786045136, -0.7633801278093398, -0.37577099825301746, 0.14629225501397528, -0.03366700906389058, -0.4992531374770084, 0.5161937494021966, 0.5548153186535513, -0.5079465545590672, -1.021287990885576, 1.8600533054767678, -1.3941301234610528, -0.5876750570891159, 0.27922173427881986, -1.1260343908468196, -1.577245894169239, 1.6868507959809638, -0.34315520906864366, 0.8756673838511702, -0.013202904846600071, 0.1663109595197368, 0.25926468816943765, 0.6214371542812759, 0.40713450838998066, 0.05660059883189231, -0.5927007106253308, 0.2144892451035325, 0.6705129011671771, -0.4192229557817511, -0.13399160735362278, -1.5234992785571666, -0.5760061861059607, 2.2972205355496347, 2.162580230059769, 1.0480461096358216, 1.0609063932362777, -1.3878584214688807, 0.6502887453513964, -1.494802096457127, 0.698933409561582, 1.0279802603891166, -0.7139967016700057, -0.7226340957160897, 0.2725587805228503, -0.10652537707272984, -0.7700645448834437, 0.4613209775995895, 0.4558764090361004, 1.2745381647988683, 1.3664038748711067, -0.5964545000969897, 0.8425859802512796, -1.1060675506974833, -0.11636201252429614, -1.130255335904117, 0.14075812150619382, 0.8628566536023579, 1.6070249894350475, 0.5703388732422935, 1.0595189144315256, -1.8499589529892804, 0.9362860024327014, -0.1535770994097404, 2.0405377240487037, 1.0763448029144767, 0.22485134726888026, 1.7007898970425377, -0.28005757238379236, 0.9570609994345478, -0.6185873758407429, -1.2014680459389429, -0.9947057654083926, -0.20067770025217516, 0.2571029176665626, -0.883927351830682, 0.12808741327939197, 0.5992307710873707, 0.12008433098103098, -0.08485212420192703, 0.31237233238563655, 0.24242726591735153, -0.06390427097507555, -1.2761512215831583, 1.4429536418920819, 1.1118445398381875, 0.04105183955117125, 0.4456661177149582, 0.7128363886693093, 1.3421394998417036, 1.4421668576965316, 0.516055009356753, -1.3147258919070557, -1.7788031740809092, -0.3713653427805966, 1.2091311389736596, 0.35425225249854947, 0.6107370879132182, -0.1414589368742329, -0.8857769913086667, 1.6322316964575883, 0.6699997627240689, -0.21740801413146052, -0.6431289330781157, -0.15060313947856438, 1.2255641097483512, -0.26336216578687954, -1.1288246390012904, 0.08564293390175488, 0.1695508442940134, -0.9549143317713982, -0.381899664359382, -0.2697790924907474, 1.1500248968433444, 0.797187566115551, -2.2555386162293702, 1.5271162429033516, -1.4448616414952375, 0.5528442713502834, 0.8665758998228781, 0.047531454194312754, -0.3979461455918577, -0.9196333950121731, 0.7723500421338588, -0.7005620370822323, -0.57814083100412, -0.3958371590421287, -0.378819582767001, 1.2092623243348053, 0.7802751224122251, 0.34213111783684963, 0.061883850451380215, 1.742883074607315, -0.07056892738486359, 1.8711704286853277, 0.5241690429678856, 0.3716901674784058, -1.125930502067472, 0.6342731753445917, 0.9179042710608684, -0.7558901282490996, 0.5333214869552843, -0.8367682885827396, -0.21003644242206773, 0.06430918371432055, -0.7963578622290897, 0.8451664890915424, 0.8390553070560024, 3.09331371860501, 0.5806724864919209, 0.107524246512258, 0.7391233418760622, 2.167266802451501, 1.725761197511158, 0.5639000495841784, 1.9213088659091762, 2.064465547549614, 0.3720730825764704, 2.3346287790204157, 2.0132997397929655, 0.09945693131810973, 0.3829898328144349, 0.6898874198125534, 1.1257384938989654, 0.21953537340589668, 0.6097059591765939, -0.21561189713349727, 1.2465459396030227, -0.5995683343209879, 1.2713435701778775, 1.7958438663665959, 3.5243926940583816, 0.16637623488520314, -0.595148222943813, -0.8999799732604659, 1.4935944403824157, 0.15500989099480322, 1.3944610481222663, 1.1848502292064618, 2.2306983335199937, 2.631909117764039, 1.4476239288590786, -0.4828925614651083, 0.11057408913563371, 0.00640265758042613, 1.7024542861313892, -0.4685410230497995, -0.18430213630815295, 0.2623725891977159, 0.8651010600032196, 4.895137812620643, 0.057026726615053036, 2.0243613671578196, 1.3771080492902819, 2.4730115106679236, 0.1971461202594893, 1.8394258496420766, 1.2843744848634882, 1.8894408827242337, 0.6230945921578759, 2.8480886863163652, 0.9630301493636445, 0.127451696378027, 1.1267301151247366, 3.0010958538312558, 0.9944362012696962, 1.7039114419652917, 5.3774940720960585, 2.1155808094041846, 0.046213804884728926, 1.810084918906268, 1.9925523580299453, -0.31312591241333365, 1.3880938367605706, -0.08451540246890765, 0.2240533204370858, -0.6578565562912071, 0.8274472171234165, -0.3289715601809369, 2.147176512563368, 1.4466993514385427, 0.44968540111451083, 0.4564834578530801, 1.6606762107322415, -0.041739938522453945, 2.2023791642408352, 1.0112816107384435, 1.345225113082646, 2.486217106182629, 1.8297521868437334, 2.0290066777972955, 0.3158590001178231, -1.2232476434957045, 0.07658643200365534, 1.9925831890740247, -0.5773731303435152, -0.7864550804461148, -0.04268872383080313, 0.26197916220629636, 1.7860902328262838, 3.1898462659158793, 1.717287023780361, 1.090626473036585, 1.3246217611648121, -1.095746094438002, -2.7811081190367952, 1.3157449164746315, 1.6742993938670452, -0.2440110274382863, -0.0011753183822658109, 0.25225221722214375, 1.3741747265636288, -0.7403493093029958, 2.937475838315583, 2.1571657126074815, -0.6710186686805126, 1.5127302375601952, 1.5504720493093065, 0.9957696771489017, 3.5218063126100776, -1.800128711362424, 2.3460110055572, 1.1259889249242794, 1.289165245585132, 2.1542501166201635, 1.971134505973963, 0.8465014430301215, 0.37398988566267366, 0.4343985704611244, -0.072934888257707, 1.3366079817789902, -1.417781571411917, -0.31924773132918594, -0.18570310576096372, -0.7520074661468574, 3.6829792376239494, -2.399176377467283, 2.1117374450882793, 0.47975838927076464, 2.303439946535707, -1.8194703787039295, -1.2711992859760306, 0.7212313105625887, 1.9368074260650436, -0.7626065329345224, 1.6422657954051356, 1.9183318402156313, -1.8689973145233099, -0.22385814705770501, 2.6721370244228138, 2.209987743572806, -0.38940376973321955, 0.003872548513662033, 2.7929375604545665, -1.9667427505487436, 1.7549433057202704, -0.48394698753375476, 2.633427290249365, 0.1310947066028515, -0.7926968054814081, 3.530981051673673, 1.2304105044346767, -0.6469977842925456, 0.8968761431101244, 0.08727309572233188, 3.756599990296251, 1.9405847822457332, 1.9202530307769865, 1.7311986553887888, -2.790797587636521, -1.3738144240750438, -0.5641528471476978, -1.6227254072521475, 0.7689829533629222, 1.3258664005482386, 2.3685985824006557, 0.9317907949520156, 3.2355955766996067, 3.24222416113727, -0.6919872654032104, 2.791740396353666, 2.907004472766578, 0.9741969791842326, 0.7995945590236447, 2.6212020255367827, 2.957602773834238, 1.0271679657187984, 2.8288675734660504, -0.7073613236052916, 0.13440485074077713, 2.9167132204505313, 3.091023354406853, -0.6289561281889586, 1.0858767473393103, 1.844928787191981, -0.47146113572262793, 1.4738263389701687, 0.6432622956589178, 1.2669449646472357, 0.6312922124559611, 1.3070450663726465, -0.32603082670360184, 0.8513571737443832, -1.5562635552907103, 2.276964485252821, 2.08168612621661 ] }, "data_meta": { "series_annotations": [ { "column": "rating", "type": "float" }, { "column": "cond", "type": "str" } ] }, "ggsize": { "height": 300.0, "width": 700.0 }, "kind": "plot", "layers": [ { "alpha": 0.7, "color": "dark_green", "geom": "density", "mapping": {}, "position": "identity", "stat": "density" } ], "mapping": { "fill": "cond", "x": "rating" }, "scales": [ { "aesthetic": "fill", "scale_mapper_kind": "color_brewer", "type": "seq" } ], "theme": { "panel_grid_major_x": "blank" } }, "output_type": "lets_plot_spec", "swing_enabled": true }, "text/html": [ "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " -3\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " -2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " -1\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 3\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.1\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.2\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.3\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " density\n", " \n", " \n", " \n", " \n", " rating\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " cond\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " A\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " B\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val rand = java.util.Random(37)\n", "val data = mapOf (\n", " \"rating\" to List(200) { rand.nextGaussian() } + List(200) { rand.nextGaussian() * 1.5 + 1 },\n", " \"cond\" to List(200) { \"A\" } + List(200) { \"B\" }\n", ")\n", "\n", "letsPlot(data) { x = \"rating\"; fill = \"cond\" } + ggsize(700, 300) +\n", " geomDensity(color = \"dark_green\", alpha = .7) + scaleFillBrewer(type = \"seq\") +\n", " theme(panelGridMajorX = \"blank\")" ] } ], "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.9.23" } }, "nbformat": 4, "nbformat_minor": 4 }