Skip to content

Chris00/rust-matplotlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Matplotlib.rs

This is a Matplotlib binding for Rust. Its interface tries to be similar to the Matplotlib one (so users knowing the Python version can easily search for the corresponding functions) but deviating whenever it makes sense (for example, to specify optional arguments) to have a nice Rust interface. Data is shared between Rust and Python (no copying, no temporary files).

This library is work in progress.

Non Rust dependencies

The binding is made using PyO3, thus you “need to ensure that your Python installation contains a shared library”. Of course you also need Matplotlib to be installed.

If you installed Python and matplotlib using anaconda, you must use conda activate to make sure the PATH is correct and also set LD_LIBRARY_PATH (on Unix) or DYLD_LIBRARY_PATH (on MacOSX) to the directory containing the Python shared library. For example, in a bash shell:

eval "$(conda shell.bash activate)"
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib

A basic example

use matplotlib as plt;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let (fig, [[mut ax]]) = plt::subplots()?;
    ax.xy(&[1., 2., 3., 4.], &[1., 4., 2., 3.]).plot();
    fig.save().to_file("basic_example.svg")?;
    Ok(())
}

Basic Example

About

A Rust interface to Matplotlib (with PyO3)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published