Lets-Plot Kotlin API is a Kotlin API for Lets-Plot Multiplatform
plotting library,
which is built on the principles of layered graphics first described in the
Leland Wilkinson work The Grammar of Graphics.
![]() |
Lets-Plot Kotlin API is largely based on the API To learn more about the Grammar of Graphics, This will be a good prerequisite for further exploration of the Lets-Plot library. |
Inside Kotlin Notebook, Datalore or Jupyter with Kotlin Kernel:
%use lets-plot
val rand = java.util.Random()
val data = mapOf(
"rating" to List(200) { rand.nextGaussian() } + List(200) { rand.nextGaussian() * 1.5 + 1.5 },
"cond" to List(200) { "A" } + List(200) { "B" }
)
var p = letsPlot(data)
p += geomDensity(color = "dark_green", alpha = .3) { x = "rating"; fill = "cond" }
p + ggsize(700, 350)
See the "Quickstart" notebook in Datalore or Jupyter nbviewer.
With the help of Lets-Plot Kotlin API you can easily create plots in Kotlin Notebook,
Datalore, Jupyter with Kotlin Kernel
or any other notebook that supports Kotlin Kernel
.
%use lets-plot
This "line magic" will apply Lets-Plot library descriptor which adds to your notebook all the boilerplate code necessary to create plots.
By default, library descriptor
is bundled with the Kotlin Jupyter Kernel installed in your environment.
However, you can override the default settings using:
%useLatestDescriptors
In this case the latest library descriptor
will be pulled from the Kotlin Jupyter Libraries repository.
%use lets-plot(api=4.4.3, lib=4.0.1, js=4.0.1, isolatedFrame=false)
api
- version of the Lets-Plot Kotlin API.lib
- version of the Lets-Plot Multiplatform (JARs).js
- version of the Lets-PLot Multiplatform JavaScript bundle.isolatedFrame
- Iffalse
: load JS just once per notebook (default in Jupyter). Iftrue
: include Lets-Plot JS in each output (default in Datalore notebooks).
To learn how to embed Lets-Plot charts in Compose Multiplatform applications, please check out the Lets-Plot Skia Frontend project.
To learn more about creating plots in JVM or Kotlin/JS environment please read USAGE_SWING_JFX_JS.md.
Examples of using of the Lets-Plot Kotlin API in JVM and Kotlin/JS applications are available in the Lets-Plot Kotlin Mini Apps (Demos) GitHub repository.
-
A quick introduction to the Grammar of Graphics and Lets-Plot Kotlin API: Lets-Plot Usage Guide
-
Lets-Plot Kotlin API docs: docs/README.md
-
Lets-Plot Kotlin API reference: https://lets-plot.org/kotlin
-
The "Example Notebooks" reference: examples.md
-
Example notebooks in the Binder: mybinder.org
Note: Due to major package refactoring in the main Lets-Plot library, this version (4.4.2) of the Kotlin API
is not compatible with versions of Lets-Plot library v3.2.0 and earlier.
- The default qualitative color palette is now Color Brewer "Set1" (was "Set2").
- Slightly bigger default size of points and width of lines.
- Flavor-aware default colors for points, lines etc.
See: example notebook.
See: example notebook.
A way to specify size of the pie in units relative to the plot size.
See: example notebook.
See: example notebook.
themeVoid()
: example.statECDF()
: example.geomFunction()
: example.statSummary()
: example.statSummaryBin()
: example.Stat.sum()
statistic: example.Stat.boxplotOutlier()
statistic: example.
See CHANGELOG.md for details.
For migration instructions see Migrating to 4.0.0 section in the CHANGELOG.
See CHANGELOG.md.
This project and the corresponding community are governed by the JetBrains Open Source and Community Code of Conduct. Please make sure you read it.
Code and documentation released under the MIT license. Copyright © 2019-2023, JetBrains s.r.o.