Awesome
Lets-Plot Kotlin API
A Grammar of Graphics for Kotlin.
Lets-Plot Kotlin API is a <a href="https://lets-plot.org/kotlin">Kotlin API</a> 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.
<a id="quickstart"></a>
Quickstart
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)
<img src="https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/images/quickstart_notebook.png" alt="Couldn't load quickstart_notebook.png" width="523" height="261"/>
<br/>
See the "Quickstart" notebook in Datalore or Jupyter nbviewer.
<a name="toc" id="toc"></a>
Table of Contents
- Usage
- Documentation
- What is new in 4.9.0
- Recent Updates in the Gallery
- Change Log
- Code of Conduct
- License
<a id="usage"></a>
Usage
<a id="in-notebook"></a>
Notebooks
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
.
"Line Magics"
%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.
Library Descriptor Parameters
%use lets-plot(api=4.9.0, lib=4.5.1, js=4.5.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).
<a id="in-compose-multiplatform"></a>
Compose Multiplatform
To learn how to embed Lets-Plot charts in Compose Multiplatform applications, please check out the Lets-Plot Skia Frontend project.
<a id="in-jvm-js"></a>
JVM and Kotlin/JS
To learn more about creating plots in JVM or Kotlin/JS environment please read USAGE_SWING_JFX_JS.md.
Examples
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 id="documentation"></a>
Documentation
-
Lets-Plot Kotlin API documentation and API reference: Lets-Plot for Kotlin
-
A quick introduction to the Grammar of Graphics and Lets-Plot Kotlin API: Lets-Plot Usage Guide
<a id="new"></a>
What is new in 4.9.0
-
Panning and Zooming
<img src="https://raw.githubusercontent.com/JetBrains/lets-plot/master/docs/f-24g/images/ggtb.png" alt="f-24g/images/ggtb.png" width="300" height="134">See example notebook.
-
Clickable Links
<img src="https://raw.githubusercontent.com/JetBrains/lets-plot/master/docs/f-24g/images/lp_verse.png" alt="f-24g/images/lp_verse.png" width="400" height="270">See example notebook.
-
LaTeX Support: Subscript, Superscript, Greek Letters and Special Characters
<img src="https://raw.githubusercontent.com/JetBrains/lets-plot/master/docs/f-24g/images/latex.png" alt="f-24g/images/latex.png" width="300" height="227">See example notebook.
-
Compact Scientific Notation Formatting
<img src="https://raw.githubusercontent.com/JetBrains/lets-plot/master/docs/f-24g/images/compact_exp.png" alt="f-24g/images/compact_exp.png" width="400" height="174">See example notebook.
-
QQ-Plot: Marginal Distributions
<img src="https://raw.githubusercontent.com/JetBrains/lets-plot/master/docs/f-24g/images/gg_marins.png" alt="f-24g/images/gg_marins.png" width="400" height="249">See example notebook.
-
More Theme Settings
<img src="https://raw.githubusercontent.com/JetBrains/lets-plot/master/docs/f-24g/images/theme_legend_scheme.png" alt="f-24g/images/theme_legend_scheme.png" width="400" height="320">See examples: legend margins, legend key, facet strip.
-
And More
See CHANGELOG.md for a full list of changes.
<a id="recent_gallery_updates"></a>
Recent Updates in the Gallery
<a href="https://nbviewer.org/github/JetBrains/lets-plot-docs/blob/master/source/kotlin_examples/cookbook/legend_theme.ipynb"> <img src="https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/Writerside/images/previews/square-legend_theme.png" alt="Customize legend appearance" width="128" height="128"> </a> <a href="https://nbviewer.org/github/JetBrains/lets-plot-docs/blob/master/source/kotlin_examples/demo/interact_pan_zoom.ipynb"> <img src="https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/Writerside/images/previews/square-interact_pan_zoom.png" alt="Zoom and Pan interactivity" width="128" height="128"> </a> <a href="https://nbviewer.org/github/JetBrains/lets-plot-docs/blob/master/source/kotlin_examples/demo/lp_verse.ipynb"> <img src="https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/Writerside/images/previews/square-lp_verse.png" alt="The observable LP-verse" width="128" height="128"> </a> <a href="https://nbviewer.org/github/JetBrains/lets-plot-docs/blob/master/source/kotlin_examples/demo/sunshine_hours.ipynb"> <img src="https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/Writerside/images/previews/square-sunshine_hours.png" alt="Sunshine hours" width="128" height="128"> </a> <a href="https://nbviewer.org/github/JetBrains/lets-plot-docs/blob/master/source/kotlin_examples/demo/us_unemployment.ipynb"> <img src="https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/Writerside/images/previews/square-us_unemployment.png" alt="Unemployment in the US since 1967" width="128" height="128"> </a> <a href="https://nbviewer.org/github/JetBrains/lets-plot-docs/blob/master/source/kotlin_examples/demo/palmer_penguins.ipynb"> <img src="https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/Writerside/images/previews/square-palmer_penguins.png" alt="Palmer penguins" width="128" height="128"> </a> <a href="https://nbviewer.org/github/JetBrains/lets-plot-docs/blob/master/source/kotlin_examples/demo/wind_rose.ipynb"> <img src="https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/Writerside/images/previews/square-wind_rose.png" alt="Wind rose" width="128" height="128"> </a><a id="change_log"></a>
Change Log
See CHANGELOG.md.
<a id="CoC"></a>
Code of Conduct
This project and the corresponding community are governed by the JetBrains Open Source and Community Code of Conduct. Please make sure you read it.
<a id="license"></a>
License
Code and documentation released under the MIT license. Copyright © 2019-2024, JetBrains s.r.o.