当前位置: 首页 > 软件库 > 神经网络/人工智能 > >

lets-plot-kotlin

授权协议 View license
开发语言 Python
所属分类 神经网络/人工智能
软件类型 开源软件
地区 不详
投 递 者 易琨
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Lets-Plot for Kotlin

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 - anopen-source plotting library for statistical data.

Lets-Plot Kotlin API is built on the principles of layered graphics first described in the Leland Wilkinsonwork The Grammar of Graphicsand 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 Guidefor 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 latestrepository 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.

Resources

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 moreabout 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/JSapplication.

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

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

Lets-Plot Kotlin API

User guide and API reference

Data sampling

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

Learn more: Data Sampling.

GGBunch

GGBunch allows to show a collection of plots on one figure. Each plot in the collection can have arbitrary location and size. There is no automatic layout inside the bunch.

Examples:

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() documentationfor more information about the function arguments and default values.

Tooltip customization

You can customize the content of tooltips for the layer by using the parameter tooltips of geom functions.

Learn more: Tooltip Customization.

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 asindividual Geometry and ReferencedEnvelope objects.

Learn more: GeoTools Support.

What is new in 3.0.2

  • Ordering categories:

    New parameters added to the asDiscrete() function:

    • orderBy - name of the variable by which the ordering will be performed;
    • order - ordering direction: 1 for ascending direction and -1 for descending (default).

    See: as_discrete.md.

  • Other improvements and fixes -see CHANGELOG.mdfor details.

Change Log

See CHANGELOG.md.

License

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

 相关资料
  • plot 可用于数据绘制与可视化,它提供了用于在 Go 中构建和绘制图的 API。 gonum/plot  被分成几个开发包: plot 包提供简单的界面布局的接口,并绘制它提供了原函数。 绘图仪包提供了一组标准的绘图仪,它使用由 plot 提供的原函数绘制线,散点图,箱线图,误差线等。 你不需要通过使用绘图仪包来利用 gonum/plot,自定义绘图仪的教程,可在维基中查看。 plotutil

  • Let's Build a Blockchain A mini cryptocurrency in Ruby Video of the talk: https://youtu.be/3aJI1ABdjQk?t=17m23s Slides here: https://speakerdeck.com/haseebq/lets-build-a-blockchain-a-mini-cryptocurrency-in-ruby

  • 绘制曲线图、饼状图。可以在图形上标注数据。 [Code4App.com]

  • pandoc-plot A Pandoc filter to generate figures from code blocks in documents pandoc-plot turns code blocks present in your documents (Markdown, LaTeX, etc.) into embedded figures, using your plotting

  • Function Plot 是一个基于 D3.js 开发的 2D 图表库,用来绘制各种函数图。 示例代码: functionPlot({  title: 'y = x * x',  target: '#linear-with-options',  width: 580,  height: 400,  disableZoom: true,  xLabel: 'x - axis',  yLabel: 

  • PowerPlot是一个iOS可视化类库,可以用于科学和商业领域的可视化图表绘制。可以绘制柱状图、折线图等等,是一个可以高度定制化的类库,满足开发者大部分可视化绘制需求。 [Code4App.com]