Royce  Reinger

Royce Reinger

1664015900

5 Favorite Data Visualization Library for Rust

In today's post we will learn about 5 Favorite Data Visualization Library for Rust.

What is Data Visualization?

Data visualization is the graphical representation of information and data. By using visual elements like charts, graphs, and maps, data visualization tools provide an accessible way to see and understand trends, outliers, and patterns in data. Additionally, it provides an excellent way for employees or business owners to present data to non-technical audiences without confusion.

In the world of Big Data, data visualization tools and technologies are essential to analyze massive amounts of information and make data-driven decisions.

Table of contents:

  • Djduque/pgfplots [pgfplots] - A Rust library to generate publication-quality figures. 
  • Igiagkiozis/plotly - Plotly for Rust.
  • Milliams/plotlib - Data plotting library for Rust.
  • Plotters - A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely. 
  • Saresend/gust - A small charting/visualization tool and partial vega implementation for Rust.

1 - Djduque/pgfplots [pgfplots]:

A Rust library to generate publication-quality figures. This crate is a PGFPlots code generator, and provides utilities to create, customize, and compile high-quality plots.

Usage

Add the following to your Cargo.toml file:

[dependencies]
pgfplots = { version = "0.4", features = ["inclusive"] }

Plotting a quadratic function is as simple as:

use pgfplots::axis::plot::Plot2D;

let mut plot = Plot2D::new();
plot.coordinates = (-100..100)
    .into_iter()
    .map(|i| (f64::from(i), f64::from(i*i)).into())
    .collect();

plot.show()?;

Examples

A more extensive list of examples and their source code is available in the examples/ directory (runnable with cargo run --all-features --example example_name).

[code][code][code]

Features

Inclusive: Allow users to process the LaTeX code that generates figures without relying on any externally installed software, configuration, or resource files. This is achieved by including the tectonic crate as a dependency.

If you already have a LaTeX distribution installed in your system, it is recommended to process the LaTeX code directly. The tectonic crate pulls in a lot of dependencies, which significantly increase compilation and processing times. Plotting a quadratic function is still very simple:

 use pgfplots::axis::plot::Plot2D;
 use std::process::{Command, Stdio};

 let mut plot = Plot2D::new();
 plot.coordinates = (-100..100)
 	.into_iter()
 	.map(|i| (f64::from(i), f64::from(i*i)).into())
 	.collect();

 let argument = plot.standalone_string().replace('\n', "").replace('\t', "");
 Command::new("pdflatex")
 	.stdout(Stdio::null())
 	.stderr(Stdio::null())
 	.arg("-interaction=batchmode")
 	.arg("-halt-on-error")
 	.arg("-jobname=figure")
 	.arg(argument)
 	.status()
 	.expect("Error: unable to run pdflatex");

View on Github

2 - Igiagkiozis/plotly:

Plotly for Rust.

A plotting library for Rust powered by Plotly.js.

Usage

Add this to your Cargo.toml:

[dependencies]
plotly = "0.8.0"

Crate Feature Flags

The following feature flags are available:

  • kaleido
    • Optional, compatible with Rust stable.
    • Adds plot save functionality to the following formats: png, jpeg, webp, svg, pdf and eps.
    • Requires some additional configuration, see plotly_kaleido.
  • plotly_ndarray
    • Optional, compatible with Rust stable.
    • Adds support for creating plots directly using ndarray types.
  • wasm
    • Optional, compatible with Rust stable.
    • Disables OS-specific functions, therefore allowing compilation in WASM environments. Note that examples won't compile when this feature is enabled, as they require OS-specific functions.

Saving to png, jpeg, webp, svg, pdf and eps formats can be made available by enabling the kaleido feature:

[dependencies]
plotly = { version = "0.8.0", features = ["kaleido"] }

For further details please see plotly_kaleido.

View on Github

3 - Milliams/plotlib:

Data plotting library for Rust.

plotlib is a generic data visualisation and plotting library for Rust. It is currently in the very early stages of development.

It can currently produce:

  • histograms
  • scatter plots
  • line graphs from data or from function definitions
  • box plots
  • bar charts

rendering them as either SVG or plain text.

The API is still very much in flux and is subject to change.

For example, code like:

use plotlib::page::Page;
use plotlib::repr::Plot;
use plotlib::view::ContinuousView;
use plotlib::style::{PointMarker, PointStyle};

fn main() {
    // Scatter plots expect a list of pairs
    let data1 = vec![
        (-3.0, 2.3),
        (-1.6, 5.3),
        (0.3, 0.7),
        (4.3, -1.4),
        (6.4, 4.3),
        (8.5, 3.7),
    ];

    // We create our scatter plot from the data
    let s1: Plot = Plot::new(data1).point_style(
        PointStyle::new()
            .marker(PointMarker::Square) // setting the marker to be a square
            .colour("#DD3355"),
    ); // and a custom colour

    // We can plot multiple data sets in the same view
    let data2 = vec![(-1.4, 2.5), (7.2, -0.3)];
    let s2: Plot = Plot::new(data2).point_style(
        PointStyle::new() // uses the default marker
            .colour("#35C788"),
    ); // and a different colour

    // The 'view' describes what set of data is drawn
    let v = ContinuousView::new()
        .add(s1)
        .add(s2)
        .x_range(-5., 10.)
        .y_range(-2., 6.)
        .x_label("Some varying variable")
        .y_label("The response of something");

    // A page with a single view is then saved to an SVG file
    Page::single(&v).save("scatter.svg").unwrap();
}

View on Github

4 - Plotters:

A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely.

Plotters is drawing library designed for rendering figures, plots, and charts, in pure rust. Plotters supports various types of back-ends, including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.

  • A new Plotters Developer's Guide is working in progress. The preview version is available at here.
  • To try Plotters with interactive Jupyter notebook, or view here for the static HTML version.
  • To view the WASM example, go to this link
  • Currently we have all the internal code ready for console plotting, but a console based backend is still not ready. See this example for how to plotting on Console with a customized backend.
  • Plotters now moved all backend code to sperate repositories, check FAQ list for details
  • Some interesting demo projects are available, feel free to try them out.

Dependencies

Ubuntu Linux

sudo apt install pkg-config libfreetype6-dev libfontconfig1-dev

Quick Start

To use Plotters, you can simply add Plotters into your Cargo.toml

[dependencies]
plotters = "0.3.1"

And the following code draws a quadratic function. src/main.rs,

use plotters::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let root = BitMapBackend::new("plotters-doc-data/0.png", (640, 480)).into_drawing_area();
    root.fill(&WHITE)?;
    let mut chart = ChartBuilder::on(&root)
        .caption("y=x^2", ("sans-serif", 50).into_font())
        .margin(5)
        .x_label_area_size(30)
        .y_label_area_size(30)
        .build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)?;

    chart.configure_mesh().draw()?;

    chart
        .draw_series(LineSeries::new(
            (-50..=50).map(|x| x as f32 / 50.0).map(|x| (x, x * x)),
            &RED,
        ))?
        .label("y = x^2")
        .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &RED));

    chart
        .configure_series_labels()
        .background_style(&WHITE.mix(0.8))
        .border_style(&BLACK)
        .draw()?;

    root.present()?;

    Ok(())
}

Demo Projects

To learn how to use Plotters in different scenarios by checking out the following demo projects:

View on Github

5 - Saresend/gust:

A small charting/visualization tool and partial vega implementation for Rust.

What is Gust

Gust is a small charting crate to make it really easy to build simple interactive data visualizations in rust. It also serves as a partial Vega implementation that will (hopefully) become more complete over time.


Gust allows you to render the actual visualizations themselves using D3.js, (meaning they're interactive!) as well as providing the flexibility to directly render the underlying JSON specification for Vega.

Currently Implementations

Currently, Gust supports only 3 charts so far:

  1. Bar Charts
  2. Stacked Bar Charts
  3. Line Charts

More will be coming soon! If you're interested in contributing your own, just make a pull request. Cheers!

Why did you do this in rust?

Installation

gust = "0.1.4"

Samples and Sample Usage

    use backend::bar_chart::BarChart;
    use frontend::write::render_graph;

Sample Bar Chart

     let mut b = BarChart::new();
        let v = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"];
        for i in 0..10 {
            b.add_data(v[i].to_string(), (i * i * i) as i32);
        }
        render_graph(&b, FileType::HTML).unwrap();

Result: gust_build/html/bar_chart.html

bar chart

Stacked Bar Chart example

use backend::stacked_bar_chart::StackedBarChart;

let mut b = StackedBarChart::new();
        for i in 0..10 {
            b.add_data(i, i * i, 1);
            b.add_data(i, i + i, 0);
        }
        render_graph(&b, FileType::HTML).unwrap();

View on Github

Thank you for following this article.

Related videos:

Visualizing memory layout of Rust's data types

#rust #datavisualization 

What is GEEK

Buddha Community

5 Favorite Data Visualization Library for Rust
 iOS App Dev

iOS App Dev

1620466520

Your Data Architecture: Simple Best Practices for Your Data Strategy

If you accumulate data on which you base your decision-making as an organization, you should probably think about your data architecture and possible best practices.

If you accumulate data on which you base your decision-making as an organization, you most probably need to think about your data architecture and consider possible best practices. Gaining a competitive edge, remaining customer-centric to the greatest extent possible, and streamlining processes to get on-the-button outcomes can all be traced back to an organization’s capacity to build a future-ready data architecture.

In what follows, we offer a short overview of the overarching capabilities of data architecture. These include user-centricity, elasticity, robustness, and the capacity to ensure the seamless flow of data at all times. Added to these are automation enablement, plus security and data governance considerations. These points from our checklist for what we perceive to be an anticipatory analytics ecosystem.

#big data #data science #big data analytics #data analysis #data architecture #data transformation #data platform #data strategy #cloud data platform #data acquisition

Sid  Schuppe

Sid Schuppe

1617988080

How To Blend Data in Google Data Studio For Better Data Analysis

Using data to inform decisions is essential to product management, or anything really. And thankfully, we aren’t short of it. Any online application generates an abundance of data and it’s up to us to collect it and then make sense of it.

Google Data Studio helps us understand the meaning behind data, enabling us to build beautiful visualizations and dashboards that transform data into stories. If it wasn’t already, data literacy is as much a fundamental skill as learning to read or write. Or it certainly will be.

Nothing is more powerful than data democracy, where anyone in your organization can regularly make decisions informed with data. As part of enabling this, we need to be able to visualize data in a way that brings it to life and makes it more accessible. I’ve recently been learning how to do this and wanted to share some of the cool ways you can do this in Google Data Studio.

#google-data-studio #blending-data #dashboard #data-visualization #creating-visualizations #how-to-visualize-data #data-analysis #data-visualisation

Gerhard  Brink

Gerhard Brink

1620629020

Getting Started With Data Lakes

Frameworks for Efficient Enterprise Analytics

The opportunities big data offers also come with very real challenges that many organizations are facing today. Often, it’s finding the most cost-effective, scalable way to store and process boundless volumes of data in multiple formats that come from a growing number of sources. Then organizations need the analytical capabilities and flexibility to turn this data into insights that can meet their specific business objectives.

This Refcard dives into how a data lake helps tackle these challenges at both ends — from its enhanced architecture that’s designed for efficient data ingestion, storage, and management to its advanced analytics functionality and performance flexibility. You’ll also explore key benefits and common use cases.

Introduction

As technology continues to evolve with new data sources, such as IoT sensors and social media churning out large volumes of data, there has never been a better time to discuss the possibilities and challenges of managing such data for varying analytical insights. In this Refcard, we dig deep into how data lakes solve the problem of storing and processing enormous amounts of data. While doing so, we also explore the benefits of data lakes, their use cases, and how they differ from data warehouses (DWHs).


This is a preview of the Getting Started With Data Lakes Refcard. To read the entire Refcard, please download the PDF from the link above.

#big data #data analytics #data analysis #business analytics #data warehouse #data storage #data lake #data lake architecture #data lake governance #data lake management

Ray  Patel

Ray Patel

1623171540

Clash of Python Data Visualization Libraries

Seaborn, Altair, and Plotly

Data visualization is a fundamental ingredient of data science. It helps us understand the data better by providing insights. We also use data visualization to deliver the results or findings.

Python, being the predominant choice of programming language in the data science ecosystem, offers a rich selection of data visualization libraries. In this article, we will do a practical comparison of 3 popular ones.

The libraries we will cover are Seaborn, Altair, and Plotly. The examples will consist of 3 fundamental data visualization types which are scatter plot, histogram, and line plot.

We will do the comparison by creating the same visualizations with all 3 libraries. We will be using the Melbourne housing dataset available on Kaggle for the examples.

#data-visualization #python #data-science #programming #clash of python data visualization libraries #libraries

Gerhard  Brink

Gerhard Brink

1624699032

Introduction to Data Libraries for Small Data Science Teams

At smaller companies access to and control of data is one of the biggest challenges faced by data analysts and data scientists. The same is true at larger companies when an analytics team is forced to navigate bureaucracy, cybersecurity and over-taxed IT, rather than benefit from a team of data engineers dedicated to collecting and making good data available.

Creative, persistent analysts find ways to get access to at least some of this data. Through a combination of daily processes to save email attachments, run database queries, and copy and paste from internal web pages one might build up a mighty collection of data sets on a personal computer or in a team shared drive or even a database.

But this solution does not scale well, and is rarely documented and understood by others who could take it over if a particular analyst moves on to a different role or company. In addition, it is a nightmare to maintain. One may spend a significant part of each day executing these processes and troubleshooting failures; there may be little time to actually use this data!

I lived this for years at different companies. We found ways to be effective but data management took up way too much of our time and energy. Often, we did not have the data we needed to answer a question. I continued to learn from the ingenuity of others and my own trial and error, which led me to the theoretical framework that I will present in this blog series: building a self-managed data library.

A data library is _not _a data warehousedata lake, or any other formal BI architecture. It does not require any particular technology or skill set (coding will not be required but it will greatly increase the speed at which you can build and the degree of automation possible). So what is a data library and how can a small data analytics team use it to overcome the challenges I’ve described?

#big data #cloud & devops #data libraries #small data science teams #introduction to data libraries for small data science teams #data science