gnuplotter/lib.rs
1//! # GnuPlotter
2//!
3//! GnuPlotter aims to enable the usage of the [gnuplot](http://www.gnuplot.info/) graphing utility
4//! from within rust code. This library is in a very early stage and I am still actively considering
5//! its use. It might not be a good productive use of my time to work on such a library as opposed
6//! to manually writing gnuplot scripts. The main selling point is that this library allows the
7//! definition of graphs within the rest of a codebase. This generally makes reasoning about the
8//! whole easier. It also allows the generated plots to be described in how they semantically fit
9//! into the larger whole of the codebase.
10//!
11//! ## Design goals
12//!
13//! There are only two major design goals at this point:
14//! - easy access to gnuplot functionality
15//! - easy customization to the needs of the engineering user
16//!
17//! ### Easy access to gnuplot functionality
18//!
19//! For engineers unfamiliar with gnuplot, it can be overwhelming to use the tool. It offers many
20//! commands and options, most of which most users won't need. An interface in Rust that documents
21//! the most commonly used functionality would make it much easier to use gnuplot at the expense of
22//! some functionality.
23//!
24//! Additionally, an engineer may choose to extend this library to expand on the gnuplot functionality
25//! made available through gnuplotter. This extension can then easily be used by other engineers in
26//! their organization.
27//!
28//! To stress the last point, gnuplotter mainly provides an approach to offer easy access to gnuplot
29//! from Rust code. It doesn't attempt to be complete, but offer a way to expand it so that most
30//! engineers in an organization don't require gnuplot knowledge.
31//!
32//! ### Easy customization over prescribing a flexible API
33//!
34//! One way to approach a plotting library would be to decide on a certain type of plot to support
35//! and then to go implement a very flexible version of it. You would decide which features to
36//! activate based on what methods are being called. For the engineers using such a library, there
37//! is a lot of API details to familiarize themselves with. I asked myself the question how this
38//! might be simplified. If I just want an x label, a y label, and a title, why do I care about the
39//! rest of a fairly complex API?
40//!
41//! The goal of gnuplotter is therefore to hide as much of the implementation details of a plot type
42//! as possible. One engineer might define a new plot type declaratively, while other engineers from
43//! that point only need to concern themselves with this very minimal API.
44//!
45//! In other words, gnuplotter enables the composition of a new plot type based on a user's specific
46//! needs, which we know very little about. The aim is to offer flexibility in the amount of
47//! plotting features made available, balanced by an ability to simplify plotting API's based on
48//! a very specific user's context.
49//!
50//! ## Solution
51//!
52//! ### Gnu commands
53//!
54//! Adding features to the library is easy. Just encode them in a struct that implements the
55//! `GnuCommandFactory` trait. A `GnuCommand` is nothing more that a way to generate a string
56//! representation of a command you would send to gnuplot yourself when using the CLI or a script.
57//!
58//! ### Composing commands
59//!
60//! These commands are then composed in a queue. A struct that consists of other elements, such as
61//! the `Axis<T>` in the example linked below, or ADT's such as `Required<T>` implement the
62//! `GnuCommandFactory` to compose the commands into a single queue.
63//!
64//! ### Rendering plots using gnuplot backend
65//!
66//! In the end, all collected commands are written to gnuplot by calling the gnuplot command from
67//! within the rust program. This is made available through a simple `CanRender` trait that is
68//! easily derived using the `Plot` macro.
69//!
70//! ## Examples
71//!
72//! ### [Basic demo](https://github.com/jamescauwelier/gnuplotter/blob/main/gnuplotter/examples/demo_basic.rs)
73//!
74//! A basic demonstration constructs a simple 2D plot with two labeled axis (X and Y) of which one
75//! is optional. It shows both how to define a plot struct and how a user can use it.
76
77pub use gnuplotter_core::required;
78pub use gnuplotter_core::maybe;
79
80pub mod prelude {
81 pub use gnuplotter_macros::*;
82 pub use gnuplotter_core::prelude::*;
83 pub use gnuplotter_core::required;
84}