Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

plotters

> DevOps
Open source

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

4.6K stars0 likes0 views
WebsiteGitHub

About

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

Plotters - A Rust drawing library focusing on data plotting for both WASM and native applications

Plotters is a 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 a work in progress. The preview version is available here.
  • Try Plotters with an 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 plot on console with a customized backend.
  • Plotters has moved some backend code to separate repositories, check FAQ list for details
  • Some interesting demo projects are available, feel free to try them out.

Gallery

To view the source code for each example, please click on the example image.

Table of Contents

  • Gallery
  • Dependencies
    • Ubuntu Linux
  • Quick Start
  • Demo Projects
  • Trying with Jupyter evcxr Kernel Interactively
  • Interactive Tutorial with Jupyter Notebook
  • Plotting in Rust
  • Plotting on HTML5 canvas with WASM Backend
  • What types of figure are supported?
  • Concepts by example
    • Drawing Backends
    • Drawing Area
    • Elements
    • Composable Elements
    • Chart Context
  • Misc
    • Development Version
    • Reducing Depending Libraries && Turning Off Backends
    • List of Features
  • FAQ List

Dependencies

Ubuntu Linux

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

Fedora Linux

sudo dnf install pkgconf freetype-devel fontconfig-devel

Quick Start

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

[dependencies]
plotters = "0.3.3"

Create the subdirectory <Cargo project dir>/plotters-doc-data

And the following code draws a quadratic function. src/main.rs writes the chart to plotters-doc-data/0.png

…

Demo Projects

To learn how to use Plotters in different scenarios, check out the following demo projects:

  • WebAssembly + Plotters: plotters-wasm-demo
  • minifb + Plotters: plotters-minifb-demo
  • GTK + Plotters: plotters-gtk-demo

Trying with Jupyter evcxr Kernel Interactively

Plotters now supports integration with evcxr and is able to interactively draw plots in Jupyter Notebook. The feature evcxr should be enabled when including Plotters to Jupyter Notebook.

The following code shows a minimal example of this.

…

Interactive Tutorial with Jupyter Notebook

This tutorial is a work in progress and isn't complete

Thanks to the evcxr, now we have an interactive tutorial for Plotters! To use the interactive notebook, you must have Jupyter and evcxr installed on your computer. Follow the instruction on this page below to install it.

After that, you should be able to start your Jupyter server locally and load the tutorial!

git clone https://github.com/38/plotters-doc-data
cd plotters-doc-data
jupyter notebook

And select the notebook called evcxr-jupyter-integration.ipynb.

Also, there's a static HTML version of this notebook available at this location

Plotting in Rust

Rust is a perfect language for data visualization. Although there are many mature visualization libraries in many different languages, Rust is one of the best languages that fits the need.

  • Easy to use Rust has a very good iterator system built into the standard library. With the help of iterators, plotting in Rust can be as easy as most of the high-level programming languages. The Rust based plotting library can be very easy to use.

  • Fast If you need to render a figure with trillions of data points, Rust is a good choice. Rust's performance allows you to combine the data processing step and rendering step into a single application. When plotting in high-level programming languages, e.g. Javascript or Python, data points must be down-sampled before feeding into the plotting program because of the performance considerations. Rust is fast enough to do the data processing and visualization within a single program. You can also integrate the figure rendering code into your application to handle a huge amount of data and visualize it in real-time.

  • WebAssembly Support Rust is one of the languages with the best WASM support. Plotting in Rust could be very useful for visualization on a web page and would have a huge performance improvement comparing to Javascript.

Plotting on HTML5 canvas with WASM Backend

Plotters currently supports a backend that uses the HTML5 canvas. To use WASM, you can simply use CanvasBackend instead of other backend and all other API remains the same!

There's a small demo for Plotters + WASM available at here. To play with the deployed version, follow this link.

What types of figure are supported?

Plotters is not limited to any specific type of figure. You can create your own types of figures easily with the Plotters API.

Plotters does provide some built-in figure types for convenience. Currently, we support line series, point series, candlestick series, and histogram. And the library is designed to be able to render multiple figure into a single image. But Plotter is aimed to be a platform that is fully extendable to support any other types of figure.

Concepts by example

Drawing Backends

Plotters can use different drawing backends, including SVG, BitMap, and even real-time rendering. For example, a bitmap drawing backend.

use plotters::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a 800*600 bitmap and start drawing
    let mut backend = BitMapBackend::new("plotters-doc-data/1.png", (300, 200));
    // And if we want SVG backend
    // let mut backend = SVGBackend::new("output.svg", (800, 600));
    backend.draw_rect((50, 50), (200, 150), &RED, true)?;
    backend.present()?;
    Ok(())
}

Drawing Area

Plotters uses a concept called drawing area for layout purpose. Plotters supports integrating multiple figures into a single image. This is done by creating sub-drawing-areas.

Besides that, the drawing area also allows for a customized coordinate system, by doing so, the coordinate mapping is done by the drawing area automatically.

use plotters::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let root_drawing_area =
        BitMapBackend::new("plotters-doc-data/2.png", (300, 200)).into_drawing_area();
    // And we can split the drawing area into 3x3 grid
    let child_drawing_areas = root_drawing_area.split_evenly((3, 3));
    // Then we fill the drawing area with different color
    for (area, color) in child_drawing_areas.into_iter().zip(0..) {
        area.fill(&Palette99::pick(color))?;
    }
    root_drawing_area.present()?;
    Ok(())
}

Elements

In Plotters, elements are the building blocks of figures. All elements are able to be drawn on a drawing area. There are different types of built-in elements, like lines, texts, circles, etc. You can also define your own element in the application code.

You may also combine existing elements to build a complex element.

To learn more about the element system, please read the element module documentation.

use plotters::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let root = BitMapBackend::new("plotters-doc-data/3.png", (300, 200)).into_drawing_area();
    root.fill(&WHITE)?;
    // Draw an circle on the drawing area
    root.draw(&Circle::new(
        (100, 100),
        50,
        Into::<ShapeStyle>::into(&GREEN).filled(),
    ))?;
    root.present()?;
    Ok(())
}

Composable Elements

Besides the built-in elements, elements can be compose

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •A new Plotters Developer's Guide is a work in progress. The preview version is available here.
  • •Try Plotters with an interactive Jupyter notebook, or view here for the static HTML version.
  • •To view the WASM example, go to this link
  • •Plotters has moved some backend code to separate repositories, check FAQ list for details
  • •Some interesting demo projects are available, feel free to try them out.
  • •Dependencies
  • •Ubuntu Linux
  • •Quick Start
  • •Demo Projects
  • •Trying with Jupyter evcxr Kernel Interactively

> Tags

Rustdata-plottinggraphingplotplotting

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理