Introducing Kravis: A Kotlin Grammar for Data Visualization
Explore the powerful capabilities of Kravis, a Kotlin library that provides a grammar for data visualization. Learn how to create a wide range of plots using a standardized set of verbs, inspired by the popular ggplot2 library in R. Discover the module architecture, supported data input formats, and output devices. Dive into the rendering options, including local R, dockerized R, and Rserve. Understand the plot immutability concept and how to use the API coverage in Kravis. Find out how to incorporate missing API elements from ggplot2 and explore other alternative JVM visualization libraries. This article serves as a comprehensive guide for software engineers, solution architects, and data scientists looking to leverage the power of Kotlin for data visualization projects.
Module Architecture
Kravis follows a module architecture that allows users to create plots with aesthetics, layers, coordinate systems, transformations, and facets. This enables mapping variables from data space to visual space, adding layers to the plot, configuring coordinate systems, applying statistical transformations, and incorporating facets.
Supported Data Input Formats
Kravis supports a variety of data input formats, including iterators and tables. Users can easily create plots using any type of iterable data, which is digested into a table and used as the data source for visualization. Additionally, Kravis seamlessly integrates with data frames, allowing users to visualize tabular data.
Output Devices
Kravis automatically detects the environment and selects the most appropriate output device for rendering plots. It can render plots using swing or JavaFX graphics devices when running in interactive mode. Alternatively, plots can be rendered directly into files or within Jupyter notebooks. Kravis supports both raster (e.g., PNG) and vector (e.g., SVG) rendering formats.
Rendering Options
Kravis provides three rendering options for binding an R engine: local R, dockerized R, and Rserve. Users can choose the rendering option that best suits their needs and configure the Kravis session preferences accordingly. This flexibility allows for seamless integration with existing R installations or the use of containerized R environments.
Plot Immutability
Similar to data frames, plots in Kravis are immutable. Users can create different versions of a plot by applying different configurations or transformations. This immutability ensures reproducibility and allows for easy comparison of variations of the same plot.
API Coverage
Kravis offers a subset of the API provided by ggplot2. While it covers a wide range of the ggplot2 functionality, some API elements may be missing. However, Kravis allows users to incorporate missing API elements from ggplot2 by using preambles and custom layer specifications. This flexibility enables users to create more custom plots and address specific use cases.
Alternative JVM Visualization Libraries
In addition to Kravis, there are several other JVM visualization libraries available. Users can explore libraries such as SmilePlot, XChart, data2viz, Kubed, plotly-scala, breeze-viz, grafana, Jzy3d, and more. Each library has its own unique features and benefits, catering to different visualization requirements and use cases.
In conclusion, Kravis is a powerful Kotlin library that provides a grammar for data visualization. It offers a wide range of plot types and customization options, making it an excellent choice for software engineers, solution architects, and data scientists. Whether you are working on a small-scale project or a large-scale data visualization application, Kravis can help you create stunning visualizations with ease.
References:
– Kravis GitHub Repository: link
– ggplot2: link
– Kotlin: link
– R: link
Acknowledgements:
– Vega-Lite Team: link
– ggplot2 Team: link
– Vega: link
Leave a Reply