• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

JetBrains/lets-plot-kotlin: Kotlin API for Lets-Plot - an open-source plotting l ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

JetBrains/lets-plot-kotlin

开源软件地址(OpenSource Url):

https://github.com/JetBrains/lets-plot-kotlin

开源编程语言(OpenSource Language):

Kotlin 100.0%

开源软件介绍(OpenSource Introduction):

Lets-Plot for Kotlin official JetBrains project

Latest Lets-Plot Kotlin API Version
Latest Lets-Plot Version
License

Overview

Lets-Plot for Kotlin is a Kotlin API for the Lets-Plot library - an open-source plotting library for statistical data.

Lets-Plot Kotlin API is built on the principles of layered graphics first described in the Leland Wilkinson work The Grammar of Graphics and later implemented in the ggplot2 package for R.

This grammar [...] is made up of a set of independent components that can be composed in many different ways. This makes [it] very powerful because you are not limited to a set of pre-specified graphics, but you can create new graphics that are precisely tailored for your problem.

Read Lets-Plot Usage Guide for quick introduction to the Grammar of Graphics and Lets-Plot Kotlin API.

Lets-Plot in Jupyter with Kotlin Kernel

Installation

In Jupyter notebook with a Kotlin Kernel, Lets-Plot library is available out-of-the-box. To install Kotlin Kernel and OpenJDK into a Conda environment, run the following command:

conda install kotlin-jupyter-kernel -c jetbrains

For more information about Jupyter Kotlin kernel, see the Kotlin kernel for Jupyter/iPython project.

"Line Magics"

You can include all the necessary Lets-Plot boilerplate code to a notebook using the following "line magic":

%use lets-plot

This will apply the lets-plot library descriptor bundled with the Kotlin Jupyter Kernel installed in your environment.

The %useLatestDescriptors line magic will force Kotlin Kernel to pull and apply the latest repository version of all library descriptors.

You can override lets-plot library descriptor settings using the lets-plot line magic parameters, like:

%use lets-plot(api=1.1.0, lib=1.5.4, js=1.5.4, isolatedFrame=false)

Where:

  • api - version of Lets-Plot Kotlin API.
  • lib - version of Lets-Plot library (JAR-s).
  • js - version of Lets-PLot JavaScript bundle.
  • isolatedFrame - If false: load JS just once per notebook (default in Jupyter). If true: include Lets-Plot JS in each output (default in Datalore notebooks)

See: Line Magics documentation in the Kotlin Jupyter project for more details.

Quickstart in Jupyter

  • In Jupyter, create a new notebook and choose the Kotlin kernel (see the instructions for more details on how to select a kernel).

  • Add the following code to a Jupyter notebook:

%use lets-plot
val rand = java.util.Random()
val data = mapOf<String, Any>(
    "rating" to List(200) { rand.nextGaussian() } + List(200) { rand.nextGaussian() * 1.5 + 1.5 },
    "cond" to List(200) { "A" } + List(200) { "B" }
)

var p = lets_plot(data)
p += geom_density(color="dark_green", alpha=.3) {x="rating"; fill="cond"}
p + ggsize(500, 250)
  • Execute the added code to evaluate the plotting capabilities of Lets-Plot.

Couldn't load quickstart.png



Example of notebooks

Try the following examples to study features of the Lets-Plot library.

Lets-Plot-Kotlin in Datalore notebooks

Datalore is an online data science notebook by JetBrains.

In Datalore notebook you can run Kotlin code directly in your browser. Many popular Kotlin libraries are preinstalled and readily available (see the list of supported Kotlin libraries).

See Quickstart in Datalore example notebook to learn more about Kotlin support in Datalore.

Watch the Datalore Getting Started Tutorial video for a quick introduction to Datalore.

Lets-Plot in JVM and Kotlin/JS application

Apart from Jupyter notebooks, Lets-Plot library and Kotlin API enables embedding plots into a JVM and a Kotlin/JS application.

See README_DEV.md to learn more about creating plots in JVM or Kotlin/JS environment.

In the lets-plot-mini-apps GitHub repository you will find examples of using Lets-Plot Kotlin API in JVM and Kotlin/JS projects.

Further Reading

User guide and API reference

Tooltip customization

You can customize the content, values formatting and appearance of tooltip for any geometry layer in your plot.

Learn more: Tooltip Customization.

Formatting

Formatting of numeric and date-time values in tooltips, legends, on the axes and text geometry layer.

Learn more: Formatting.

Data sampling

Sampling is a special technique of data transformation, which helps to deal with large datasets and overplotting.

Learn more: Data Sampling.

Saving plot to a file

The ggsave() function is a convenient way of saving a plot or a GGBunch object to a file.

The supported export formats are: SVG, HTML, PNG, JPEG and TIFF.

For example, the code below will save plot as a PNG image to the file <user dir>//lets-plot-images/density.png:

%use lets-plot

val rand = java.util.Random(123)
val n = 400
val data = mapOf (
    "rating" to List(n/2) { rand.nextGaussian() } + List(n/2) { rand.nextGaussian() * 1.5 + 1.5 },
    "cond" to List(n/2) { "A" } + List(n/2) { "B" }
)

var p = lets_plot(data) +
        geom_density { x = "rating"; color = "cond" } + ggsize(500, 250)
        
ggsave(p, "density.png")        

Couldn't load ggsave_demo.png


See ggsave() documentation for more information about the function arguments and default values.

GeoTools support

GeoTools is an open source Java GIS Toolkit.

Lets-Plot supports visualization of a set of SimpleFeature-s stored in SimpleFeatureCollection, as well as individual Geometry and ReferencedEnvelope objects.

Learn more: GeoTools Support.

What is new in 3.3.0

  • New Plot Types

    • Quantile-Quantile (Q-Q) plot.

      • geometries:
        • geomQQ()
        • geomQQLine()
        • geomQQ2()
        • geomQQ2Line()
      • stats:
        • statQQ()
        • statQQLine()
        • statQQ2()
        • statQQ2Line()
      • quick Q-Q: qqPlot()

      See: example notebook.

    • Marginal plots.

      f-22b/images/marginal_layers.png

      See: example notebook.

  • Plot Theme

  • Color Scales

    scaleColorGradientN() and scaleFillGradientN() functions.

    See: example notebook.

  • Deprecated API

(!) Potentially breaking change: deprecation level for all deprecated API raised to the ERROR level.

  • Other improvements and fixes

    See CHANGELOG.md for details.

Change Log

See CHANGELOG.md.

License

Code and documentation released under the MIT license. Copyright © 2019-2022, JetBrains s.r.o.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap