A Rust library for drawing plots, powered by Gnuplot.

Overview

RustGnuplot

A Gnuplot controller written in Rust.

Build Status

Documentation

See here

Examples

A simple example:

let mut fg = Figure::new();
fg.axes2d()
	.set_title("A plot", &[])
	.set_legend(Graph(0.5), Graph(0.9), &[], &[])
	.set_x_label("x", &[])
	.set_y_label("y^2", &[])
	.lines(
		&[-3., -2., -1., 0., 1., 2., 3.],
		&[9., 4., 1., 0., 1., 4., 9.],
		&[Caption("Parabola")],
	);
fg.show().unwrap();

Simple example plot

A somewhat involved 2D example (see example1.rs in the examples directory):

Complicated example plot

Features

  • Simple 2D plots
    • lines
    • points
    • points + lines
    • error bars
    • ...and more!
  • Simple 3D plots
    • surface plots
    • heatmaps
    • contours

Building

Via Cargo

cargo build
Comments
  • Interactive gnuplot window

    Interactive gnuplot window

    When using fg.show() a nice gnuplot window pops up and everything is good until I try to zoom or move around or in any way interact with the window. As far as I understand this is normal behavior when using the -p gnuplot parameter.

    I think it would be better to use pause mouse close as the last command instead of -p. This command keeps the gnuplot process running until the window is closed and is probably better than -p since the window becomes interactive.

    Currently I am using this workaround, but if you agree I think this would be a nice addition to the library.

    let p = Command::new("gnuplot")
        .arg("/dev/stdin")
        .stdin(Stdio::piped())
        .spawn().unwrap();
    
    let mut stdin = p.stdin.unwrap();
    fig.echo(&mut stdin);
    stdin.write_all(b"pause mouse close\n").unwrap();
    
    opened by birktj 10
  • fg.show() doesn't do anything

    fg.show() doesn't do anything

    I have the following code:

    // myexample.rs
    let mut fg = Figure::new();
        
    fg.set_terminal("qt", "");
    
    fg.axes2d()
            .lines(&times, &lambda_values,
                &[
                    Caption("λ(t)"),
                    Color("#1E90FF"),
                ])
            .points(&event_times, &event_intens, 
                &[
                    Caption("Events"),
                    Color("black"),
                    PointSymbol('O'),
                    PointSize(0.8)])
            .set_x_label("Temps t", &[])
            .set_y_label("Intensité", &[]);
        
    fg.show();
    

    But when I run cargo run --example myexample, the gnuplot window doesn't show up (not even for a split second). When I choose a different backend such as pngcairo and an output file, it won't create the file either. I have to echo to a .gnuplot file and run gnuplot manually.

    I'm running Windows 10 64-bit, with Rust 1.26.2 and gnuplot 5.3.

    opened by ManifoldFR 5
  • Reverse x, y, z axes

    Reverse x, y, z axes

    In axes_common.rs:

    • in struct AxisData, add field reverse: bool.
    • in AxisData::new(), initialize struct with reverse: false.
    • in AxisData::write_out_commands(), write reverse.
    • add AxisData::set_reverse() method.
    • in trait AxesCommon : AxesCommonPrivate add set_x_reverse() and set_y_reverse() methods.

    In axes3d.rs:

    • add method set_z_reverse to Axes3D.
    opened by hwchen 5
  • How to detect whether the gnuplot terminal is still running?

    How to detect whether the gnuplot terminal is still running?

    I want my rust code to loop {} until the plot window is closed. How do I do this?

    This is needed, as most gnuplot terminals loose control facilities if the their gnuplot process dies, which always happens if the rust program which spawned gnuplot dies. So in order to have that rust program wait for the gnuplot terminal to terminate, one needs to know whether gnuplot is still running.

    opened by wucke13 4
  • Add support for multiplot options

    Add support for multiplot options

    I re-implemented the multiplot options from pull request #47 using @SiegeLord's feedback on the API and where to generate the gnuplot commands. I also added an example showing how to use the new options.

    opened by tomwhatmore 4
  • Feature intoiterator

    Feature intoiterator

    Hi,

    This patch relaxes the input type of all methods from Iterator<_> to IntoIterator<_>. Since every Iterator implements IntoIterator, this does not break any old code. On the other hand, it allows for a more ergonomic code:

    let x = [0i32, 1, 2];
    fg.axes2d().lines(&x, ...);
    

    and such.

    I had to update the examples since they do not build on nightly anymore. I have removed all unstable features so the examples now build on the stable branch.

    opened by rekka 4
  • update docs: suggest close()-ing

    update docs: suggest close()-ing

    not doing a close() on a figure leaves an unterminated zombie process in the operating system.

    It makes sense to suggest best practices regarding resource management right in the main docs.

    opened by vn971 3
  • Not alternating colors when drawing lines

    Not alternating colors when drawing lines

    Not sure if I'm doing anything wrong but with this example both lines are drawn using the same color, making impossible to distinguish them. Using points() instead of lines() does alternate the color and pattern. Shouldn't lines() do it as well?

    use gnuplot::*;
    
    fn main() {
        let mut fg = Figure::new();
    
        fg.axes2d()
            .lines(&[1, 2, 3], &[1, 2, 3], &[Caption("fst")])
            .lines(&[1, 2, 3], &[4, 5, 6], &[Caption("snd")]);
    
        fg.show();
    }
    
    opened by gdesmott 3
  • String labels for xtic

    String labels for xtic

    I was creating a bar chart using this library but found that it would not allow for strings to be attached to xtics. If this could be added it would be immensely useful for creating bar charts.

    opened by bonorumetmalorum 3
  • Errorbars on points without connecting lines?

    Errorbars on points without connecting lines?

    Thanks for this nice library! I discovered that RustGnuplot uses gnuplot's errorlines in order to plot points with error bars. Is there a way to use errorbar instead? If i understand the documentation correctly, one could achieve the former by using errorbar + plot. On the other hand it seems like one cannot turn off the lines once they are plotted with errorlines. I also tried setting the linewidth to 0 to no avail. Am I missing something?

    opened by cbourjau 3
  • fixes for latest rust nightly

    fixes for latest rust nightly

    This fixes issue #6, I'm not entirely sure this is the best way to fix it but as far as I can tell it works. I fixed it by passing borrowed references to the member, instead of moving out of it.

    opened by semitom 3
Owner
null
A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely 🦀 📈🚀

Plotters - A Rust drawing library focus on data plotting for both WASM and native applications ?? ?? ?? Plotters is drawing library designed for rende

Hao Hou 2.7k Jan 4, 2023
Data plotting library for Rust

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

Matt Williams 417 Dec 31, 2022
A pure Rust visualization library inspired by D3.js

charts A pure Rust visualization library inspired by D3.js. See gallery and examples for code and more charts. Install You can add this as a dependenc

Iulian Gulea 186 Dec 29, 2022
A library to generate syntax diagrams for Rust macros.

Live demo (code) A browser add-on for Firefox, Chrome and Edge A library to generate syntax ("railroad") diagrams for Rust's macro_rules!(). Diagrams

null 468 Jan 6, 2023
A library of to show data (in browser, evcxr_jupyter) as table, chart...

showata A library of to show data (in browser, evcxr_jupyter) as table, chart.... The crate provides display for: image vector and slice (as table) nd

Procyon 20 Dec 12, 2022
A simple 2D plotting library that outputs graphs to SVG that can be styled using CSS.

Poloto graphs can be stylized using css either directly in the SVG, or from inside of html with an embedded svg. The latter allows the user to dynamically match the svg to their website's theme.

Ken Reed 119 Dec 13, 2022
A small charting/visualization tool and partial vega implementation for Rust

Gust A charting library for rust! Disclaimer This is still very much a work in progress! APIs are very unstable and subject to change. Contributions a

Samuel Resendez 128 Dec 24, 2022
Plotly for Rust

Plotly.rs Plotly for Rust Getting Started | Recipes | API Docs | Changelog | | | A plotting library for Rust powered by Plotly.js. Usage Add this to y

Ioannis Giagkiozis 671 Jan 8, 2023
This is a Rust implementation of a boid flocking simulation using the ggez graphics crate.

Boidflock This is a Rust implementation of a boid flocking simulation using the ggez graphics crate. The CLI for this program is built using the struc

Andrew Lee 12 Jan 4, 2023
Swash is a pure Rust, cross-platform crate that provides font introspection, complex text shaping and glyph rendering.

Swash is a pure Rust, cross-platform crate that provides font introspection, complex text shaping and glyph rendering. Goals This crate aims to

Chad Brokaw 398 Dec 14, 2022
Render farm simulator & plotting for optimisation written in Rust.

Farm Usage Simulator Given a few basic charasteristics of a render farm and render jobs this app runs a few randomized farm usage scenarios and plots

ford 2 Jul 17, 2022
Rust crate for creating beautiful interactive Chord Diagrams

Chord PRO Released Chord PRO is the full-featured chord visualization API, producing beautiful interactive visualizations, e.g. those featured on the

Dr. Shahin Rostami 25 Sep 10, 2022
A Rust API for Vega-Lite V4 to build chart with a rusty API.

Vega-Lite V4 for Rust A Rust API for Vega-Lite V4 to build chart with a rusty API. Similar to the Altair project in python, this crate build upon Vega

Procyon 18 Nov 26, 2022
Graphical Rust program that uses a fractal algorithm to draw a tree of sorts

rusty-vegetation Graphical Rust program that uses a fractal algorithm to draw a "tree" of sorts. To Build and Run On Linux: Install build-essentials o

Stephen G Tuggy 4 Dec 4, 2022
A Rust program for visualizing how sections get packed into your Game Boy ROM

GB Packing Visualizer A Rust program for visualizing how sections get packed into your Game Boy ROM. rhythm_land.mp4 Each column represents a ROM bank

Eldred Habert 6 Jan 31, 2022
Lightweight graphs (sparklines) for use with Embedded Rust

Sparklines for Rust's Embedded-graphics Sparklines are small, high resolution graphics embedded in a context of words, numbers or images". Edward Tuft

Bernard Kobos 4 Aug 28, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Externalize easily the plotting process from Rust to gnuplot.

preexplorer Easy plotter and saver of simple data. Handy tool for development stage or small computational projects. Save data, have a quick view and

Raimundo Saona 4 Jan 7, 2022
A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely 🦀 📈🚀

Plotters - A Rust drawing library focus on data plotting for both WASM and native applications ?? ?? ?? Plotters is drawing library designed for rende

Hao Hou 2.7k Jan 4, 2023