JetBrains/lets-plot-kotlin
关于
适用于 Kotlin 的图形语法。
创作与媒体实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Lets-Plot Kotlin API
A Grammar of Graphics for Kotlin.
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. |
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)
See the "Quickstart" notebook in Datalore or Jupyter nbviewer.
Table of Contents
Usage
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(v=4.15.0, isolatedFrame=false, output="js, ktnb, svg")
v- version of the Lets-Plot Kotlin API.isolatedFrame- Iffalse: load JS just once per notebook (default in Jupyter).
Iftrue: include Lets-Plot JS in each output (default in Datalore notebooks).output- comma-separated list of output types to store in notebook cells (default:"js, ktnb, svg"). \
Available types:js- Classic Web output: HTML+JSktnb- Kotlin Notebook Swing-based renderingsvg- Static SVG outputpng- Static PNG output
Note: Static images (SVG/PNG) are hidden when
jsorktnboutputs are present, and only displayed in environments where JavaScript is not executed (e.g., GitHub).This option can be helpful when file size becomes a problem. For example, storing only static output (SVG or PNG) can significantly reduce file size when working with large datasets where plot interactivity is not a priority.
Compose Multiplatform
To learn how to embed Lets-Plot charts in Compose Multiplatform applications, please check out the Lets-Plot Compose Frontend project at GitHub.
JVM and Kotlin/JS
To learn more about creating plots in JVM or Kotlin/JS environment, please read USAGE_JVM_JS.md.
Examples
Examples of using the Lets-Plot Kotlin API in JVM and Kotlin/JS applications are available in the Lets-Plot Kotlin Mini Apps (Demos) GitHub repository.
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
Recent Updates in the Gallery
Change Log
See CHANGELOG.md.
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.
License
Code and documentation released under the MIT license. Copyright © 2019-2025, JetBrains s.r.o.
探索相关项目
加载中…