Plotting libraries

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 and Plotly.

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 :slight_smile:

2 Likes

Integrated in my KotlinLab project:

I have integrated MATLAB like plotting routines.

1 Like

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.

1 Like

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

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.

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.