# Plotting libraries

**URL:** <https://discuss.kotlinlang.org/t/plotting-libraries/24625>\
**Category:** Support\
**Created:** [April 15, 2022, 8:03am UTC](https://discuss.kotlinlang.org/t/plotting-libraries/24625 "2022-04-15T08:03:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexis.manin](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/alexis.manin/32/8381_2.png) [@alexis.manin](https://discuss.kotlinlang.org/u/alexis.manin)\
**Post date:** [April 15, 2022, 8:03am UTC](https://discuss.kotlinlang.org/t/plotting-libraries/24625/1 "2022-04-15T08:03:54Z")

</div>

Hello,

I’d like to run some plotting some simple line and scatter dataset using Kotlin (JVM for now).

By looking here and there, I’ve found two libraries that could fit my need : [Lets-plot](https://github.com/JetBrains/lets-plot-kotlin) and [Plotly](https://github.com/mipt-npm/plotly.kt).

As I do not know the R/Python libraries that inspired the tools, I’m rather neutral about user API.

However, I’m wondering if there’s some limitations about one or the other that I should be warned about. For now, I just want to create static plots and save them in a png or svg file.

In the future, I might try to create interactive plots, but that is not a requirement for now.

Do you know of any limitation in one of the libraries that I should be aware of ?

If you have tried them, what is your preference ? Why ? (fewer dependencies, API paradigme, performance, etc.)

Thanks for your time 🙂

---

<div class="post-metadata">

**Author:** ![sterg](https://avatars.discourse-cdn.com/v4/letter/s/a587f6/32.png) [@sterg](https://discuss.kotlinlang.org/u/sterg)\
**Post date:** [April 15, 2022, 9:03am UTC](https://discuss.kotlinlang.org/t/plotting-libraries/24625/2 "2022-04-15T09:03:20Z")

</div>

Integrated in my KotlinLab project:

> **[GitHub - sterglee/KotlinLabSimple: A MATLAB-like scientific scripting...](https://github.com/sterglee/KotlinLabSimple)**
>
> A MATLAB-like scientific scripting environment for Kotlin, a simpler Kotlin only version of KotlinLab. Java 16 or newer is required to run KotlinLabSimple - GitHub - sterglee/KotlinLabSimple: A MAT...

I have integrated MATLAB like plotting routines.

---

<div class="post-metadata">

**Author:** ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Post date:** [April 15, 2022, 3:24pm UTC](https://discuss.kotlinlang.org/t/plotting-libraries/24625/3 "2022-04-15T15:24:25Z")

</div>

Plotly.kt uses Plotly-js library. The same one which is used in Python. It is pretty comperhansive, but since it is a JS library, you need a browser to render plots. If you want to use browser / notebook - it is perfectly fine, but if you want to embed it into application, it is harder. Plotly and plotly.kt do support interactive plots and dynamically updating plots (it is even much better than in Python since it uses a unique metadata tree updates mechanics and coroutines). Plotly.kt uses JS API as a base, but adds a few kotlin-specific tweaks.

Lets-plot uses native rendering so it is available everywhere, but interactivity is quite limited (for now). For me the main problem with lets-plot is that it uses R-style API which is not Kotlin-friendly.

Currently, there is some work being done to create a more universal plotting API, which will unite all libraries.

---

<div class="post-metadata">

**Author:** ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Post date:** [April 15, 2022, 3:25pm UTC](https://discuss.kotlinlang.org/t/plotting-libraries/24625/4 "2022-04-15T15:25:17Z")

</div>

As always, the discussion is welcome in kotl.in/slack `science` and `datascience` channels.

---

<div class="post-metadata">

**Author:** ![alexis.manin](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/alexis.manin/32/8381_2.png) [@alexis.manin](https://discuss.kotlinlang.org/u/alexis.manin)\
**Post date:** [April 19, 2022, 7:30am UTC](https://discuss.kotlinlang.org/t/plotting-libraries/24625/5 "2022-04-19T07:30:30Z")

</div>

Thanks for the insights, it will be very useful. By curiosity, can you provide some links (discussions, draft, etc.) about the “universal plotting API” ? I’ve not found much by myself.

---

<div class="post-metadata">

**Author:** ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Post date:** [April 19, 2022, 7:49am UTC](https://discuss.kotlinlang.org/t/plotting-libraries/24625/6 "2022-04-19T07:49:00Z")

</div>

So far it mostly involves prototypes and discussion. I think the best place is slack “science” channel. There is not clea consensus about how to approach this problem. For example there is a question about how to treat data. Should it be a part of plots API (like in lets-plot or JFreeChart) or should be a separate thing. I think I will organize some discussion sessions about that in future.
