[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5814":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":34,"readmeContent":35,"aiSummary":36,"trendingCount":16,"starSnapshotCount":16,"syncStatus":37,"lastSyncTime":38,"discoverSource":39},5814,"plotters","plotters-rs\u002Fplotters","plotters-rs","A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely 🦀 📈🚀","https:\u002F\u002Fplotters-rs.github.io\u002Fhome\u002F",null,"Rust",4581,318,40,155,0,1,11,29.51,"MIT License",false,"master",true,[25,26,27,28,29,30,31,32,33],"data-plotting","graphing","plot","plotting","rust","rust-crate","science","visualization","webassembly","2026-06-12 02:01:15","# Plotters - A Rust drawing library focusing on data plotting for both WASM and native applications 🦀📈🚀\n\n\u003Ca href=\"https:\u002F\u002Fcrates.io\u002Fcrates\u002Fplotters\">\n    \u003Cimg style=\"display: inline!important\" src=\"https:\u002F\u002Fimg.shields.io\u002Fcrates\u002Fv\u002Fplotters.svg\">\u003C\u002Fimg>\n\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fdocs.rs\u002Fplotters\">\n    \u003Cimg style=\"display: inline!important\" src=\"https:\u002F\u002Fdocs.rs\u002Fplotters\u002Fbadge.svg\">\u003C\u002Fimg>\n\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fdocs.rs\u002Fplotters\">\n    \u003Cimg style=\"display: inline!important\" src=\"https:\u002F\u002Fimg.shields.io\u002Fcrates\u002Fd\u002Fplotters\">\u003C\u002Fimg>\n\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fplotters-rs.github.io\u002Frustdoc\u002Fplotters\u002F\">\n\t\u003Cimg style=\"display: inline! important\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdocs-development-lightgrey.svg\">\u003C\u002Fimg>\n\u003C\u002Fa>\n\nPlotters is a drawing library designed for rendering figures, plots, and charts, in pure Rust. Plotters supports various types of back-ends, \nincluding bitmap, vector graph, piston window, GTK\u002FCairo and WebAssembly. \n\n- A new Plotters Developer's Guide is a work in progress. The preview version is available [here](https:\u002F\u002Fplotters-rs.github.io\u002Fbook).\n- Try Plotters with an interactive Jupyter notebook, or view [here](https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fevcxr-jupyter-integration.html) for the static HTML version.\n- To view the WASM example, go to this [link](https:\u002F\u002Fplotters-rs.github.io\u002Fwasm-demo\u002Fwww\u002Findex.html)\n- Currently we have all the internal code ready for console plotting, but a console based backend is still not ready. See [this example](https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fconsole.rs) for how to plot on console with a customized backend.\n- Plotters has moved some backend code to separate repositories, check [FAQ list](#faq-list) for details\n- Some interesting [demo projects](#demo-projects) are available, feel free to try them out.\n\n## Gallery\n\nTo view the source code for each example, please click on the example image.\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fchart.rs\">\n    \u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fsample.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fstock.rs\">\n    \u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fstock.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fhistogram.rs\">\n    \u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fhistogram.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters#quick-start\">\n    \u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002F0.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"#\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fconsole-2.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fmandelbrot.rs\">\n    \u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fmandelbrot.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters#trying-with-jupyter-evcxr-kernel-interactively\">\n    \u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fevcxr_animation.gif\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters-piston\u002Fblob\u002Fmaster\u002Fexamples\u002Fcpustat.rs\">\n    \u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fplotters-piston.gif\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fnormal-dist.rs\">\n    \u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fnormal-dist.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Ftwo-scales.rs\">\n    \u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Ftwoscale.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fmatshow.rs\">\n    \u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fmatshow.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fsierpinski.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fsierpinski.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fnormal-dist2.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fnormal-dist2.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Ferrorbar.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Ferrorbar.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fslc-temp.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fslc-temp.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Farea-chart.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Farea-chart.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fsnowflake.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fsnowflake.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fanimation.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fanimation.gif\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fconsole.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fconsole-example.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fconsole.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fconsole.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fblit-bitmap.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fblit-bitmap.png\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Fboxplot.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fboxplot.svg\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002F3d-plot.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002F3d-plot.svg\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002F3d-plot2.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002F3d-plot2.gif\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters\u002Fblob\u002Fmaster\u002Fplotters\u002Fexamples\u002Ftick_control.rs\">\n\t\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Ftick_control.svg\" class=\"galleryItem\" width=200px>\u003C\u002Fimg>\n\u003C\u002Fa>\n\n\n## Table of Contents\n  * [Gallery](#gallery)\n  * [Dependencies](#dependencies)\n    + [Ubuntu Linux](#ubuntu-linux)\n  * [Quick Start](#quick-start)\n  * [Demo Projects](#demo-projects)\n  * [Trying with Jupyter evcxr Kernel Interactively](#trying-with-jupyter-evcxr-kernel-interactively)\n  * [Interactive Tutorial with Jupyter Notebook](#interactive-tutorial-with-jupyter-notebook)\n  * [Plotting in Rust](#plotting-in-rust)\n  * [Plotting on HTML5 canvas with WASM Backend](#plotting-on-html5-canvas-with-wasm-backend)\n  * [What types of figure are supported?](#what-types-of-figure-are-supported)\n  * [Concepts by example](#concepts-by-example)\n    + [Drawing Backends](#drawing-backends)\n    + [Drawing Area](#drawing-area)\n    + [Elements](#elements)\n    + [Composable Elements](#composable-elements)\n    + [Chart Context](#chart-context)\n  * [Misc](#misc)\n    + [Development Version](#development-version)\n    + [Reducing Depending Libraries && Turning Off Backends](#reducing-depending-libraries--turning-off-backends)\n    + [List of Features](#list-of-features)\n  * [FAQ List](#faq-list)\n\n## Dependencies\n\n### Ubuntu Linux\n\n ```sudo apt install pkg-config libfreetype6-dev libfontconfig1-dev```\n\n### Fedora Linux\n\n ```sudo dnf install pkgconf freetype-devel fontconfig-devel```\n\n## Quick Start\n\nTo use Plotters, you can simply add Plotters into your `Cargo.toml`\n```toml\n[dependencies]\nplotters = \"0.3.3\"\n```\nCreate the subdirectory `\u003CCargo project dir>\u002Fplotters-doc-data`\n\nAnd the following code draws a quadratic function. `src\u002Fmain.rs` writes the chart to `plotters-doc-data\u002F0.png`\n\n```rust\nuse plotters::prelude::*;\nfn main() -> Result\u003C(), Box\u003Cdyn std::error::Error>> {\n    let root = BitMapBackend::new(\"plotters-doc-data\u002F0.png\", (640, 480)).into_drawing_area();\n    root.fill(&WHITE)?;\n    let mut chart = ChartBuilder::on(&root)\n        .caption(\"y=x^2\", (\"sans-serif\", 50).into_font())\n        .margin(5)\n        .x_label_area_size(30)\n        .y_label_area_size(30)\n        .build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)?;\n\n    chart.configure_mesh().draw()?;\n\n    chart\n        .draw_series(LineSeries::new(\n            (-50..=50).map(|x| x as f32 \u002F 50.0).map(|x| (x, x * x)),\n            &RED,\n        ))?\n        .label(\"y = x^2\")\n        .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &RED));\n\n    chart\n        .configure_series_labels()\n        .background_style(&WHITE.mix(0.8))\n        .border_style(&BLACK)\n        .draw()?;\n\n    root.present()?;\n\n    Ok(())\n}\n```\n\n![](https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002F0.png)\n\n## Demo Projects\n\nTo learn how to use Plotters in different scenarios, check out the following demo projects:\n\n- WebAssembly + Plotters: [plotters-wasm-demo](https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters-wasm-demo)\n- minifb + Plotters: [plotters-minifb-demo](https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters-minifb-demo)\n- GTK + Plotters: [plotters-gtk-demo](https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters-gtk-demo) \n\n\n## Trying with Jupyter evcxr Kernel Interactively\n\nPlotters now supports integration with `evcxr` and is able to interactively draw plots in Jupyter Notebook.\nThe feature `evcxr` should be enabled when including Plotters to Jupyter Notebook.\n\nThe following code shows a minimal example of this.\n\n```text\n:dep plotters = { version = \"^0.3.6\", default-features = false, features = [\"evcxr\", \"all_series\", \"all_elements\"] }\nextern crate plotters;\nuse plotters::prelude::*;\n\nlet figure = evcxr_figure((640, 480), |root| {\n    root.fill(&WHITE)?;\n    let mut chart = ChartBuilder::on(&root)\n        .caption(\"y=x^2\", (\"Arial\", 50).into_font())\n        .margin(5)\n        .x_label_area_size(30)\n        .y_label_area_size(30)\n        .build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)?;\n\n    chart.configure_mesh().draw()?;\n\n    chart.draw_series(LineSeries::new(\n        (-50..=50).map(|x| x as f32 \u002F 50.0).map(|x| (x, x * x)),\n        &RED,\n    )).unwrap()\n        .label(\"y = x^2\")\n        .legend(|(x,y)| PathElement::new(vec![(x,y), (x + 20,y)], &RED));\n\n    chart.configure_series_labels()\n        .background_style(&WHITE.mix(0.8))\n        .border_style(&BLACK)\n        .draw()?;\n    Ok(())\n});\nfigure\n```\n\n\u003Cimg src=\"https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fevcxr_animation.gif\" width=\"450px\">\u003C\u002Fimg>\n\n## Interactive Tutorial with Jupyter Notebook\n\n*This tutorial is a work in progress and isn't complete*\n\nThanks to the evcxr, now we have an interactive tutorial for Plotters!\nTo use the interactive notebook, you must have Jupyter and evcxr installed on your computer. \nFollow the instruction on [this page](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fevcxr\u002Ftree\u002Fmaster\u002Fevcxr_jupyter) below to install it.\n\nAfter that, you should be able to start your Jupyter server locally and load the tutorial!\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002F38\u002Fplotters-doc-data\ncd plotters-doc-data\njupyter notebook\n```\n\nAnd select the notebook called `evcxr-jupyter-integration.ipynb`.\n\nAlso, there's a static HTML version of this notebook available at [this location](https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002Fevcxr-jupyter-integration.html)\n\n## Plotting in Rust\n\nRust 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.\n\n* **Easy to use** Rust has a very good iterator system built into the standard library. With the help of iterators,\nplotting in Rust can be as easy as most of the high-level programming languages. The Rust based plotting library\ncan be very easy to use.\n\n* **Fast** If you need to render a figure with trillions of data points, \nRust is a good choice. Rust's performance allows you to combine the data processing step \nand rendering step into a single application. When plotting in high-level programming languages,\ne.g. Javascript or Python, data points must be down-sampled before feeding into the plotting \nprogram because of the performance considerations. Rust is fast enough to do the data processing and visualization \nwithin a single program. You can also integrate the \nfigure rendering code into your application to handle a huge amount of data and visualize it in real-time.\n\n* **WebAssembly Support** Rust is one of the languages with the best WASM support. Plotting in Rust could be \nvery useful for visualization on a web page and would have a huge performance improvement comparing to Javascript.\n\n## Plotting on HTML5 canvas with WASM Backend\n\nPlotters currently supports a backend that uses the HTML5 canvas. To use WASM, you can simply use \n`CanvasBackend` instead of other backend and all other API remains the same!\n\nThere's a small demo for Plotters + WASM available at [here](https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters-wasm-demo). \nTo play with the deployed version, follow this [link](https:\u002F\u002Fplotters-rs.github.io\u002Fwasm-demo\u002Fwww\u002Findex.html).\n\n## What types of figure are supported?\n\nPlotters is not limited to any specific type of figure.\nYou can create your own types of figures easily with the Plotters API.\n\nPlotters does provide some built-in figure types for convenience.\nCurrently, we support line series, point series, candlestick series, and histogram.\nAnd the library is designed to be able to render multiple figure into a single image.\nBut Plotter is aimed to be a platform that is fully extendable to support any other types of figure.\n\n## Concepts by example\n\n### Drawing Backends\nPlotters can use different drawing backends, including SVG, BitMap, and even real-time rendering. For example, a bitmap drawing backend.\n\n```rust\nuse plotters::prelude::*;\nfn main() -> Result\u003C(), Box\u003Cdyn std::error::Error>> {\n    \u002F\u002F Create a 800*600 bitmap and start drawing\n    let mut backend = BitMapBackend::new(\"plotters-doc-data\u002F1.png\", (300, 200));\n    \u002F\u002F And if we want SVG backend\n    \u002F\u002F let mut backend = SVGBackend::new(\"output.svg\", (800, 600));\n    backend.draw_rect((50, 50), (200, 150), &RED, true)?;\n    backend.present()?;\n    Ok(())\n}\n```\n\n![](https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002F1.png)\n\n### Drawing Area\nPlotters uses a concept called drawing area for layout purpose.\nPlotters supports integrating multiple figures into a single image.\nThis is done by creating sub-drawing-areas.\n\nBesides that, the drawing area also allows for a customized coordinate system, by doing so, the coordinate mapping is done by the drawing area automatically.\n\n```rust\nuse plotters::prelude::*;\nfn main() -> Result\u003C(), Box\u003Cdyn std::error::Error>> {\n    let root_drawing_area =\n        BitMapBackend::new(\"plotters-doc-data\u002F2.png\", (300, 200)).into_drawing_area();\n    \u002F\u002F And we can split the drawing area into 3x3 grid\n    let child_drawing_areas = root_drawing_area.split_evenly((3, 3));\n    \u002F\u002F Then we fill the drawing area with different color\n    for (area, color) in child_drawing_areas.into_iter().zip(0..) {\n        area.fill(&Palette99::pick(color))?;\n    }\n    root_drawing_area.present()?;\n    Ok(())\n}\n```\n\n![](https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002F2.png)\n\n### Elements\n\nIn Plotters, elements are the building blocks of figures. All elements are able to be drawn on a drawing area.\nThere are different types of built-in elements, like lines, texts, circles, etc.\nYou can also define your own element in the application code.\n\nYou may also combine existing elements to build a complex element.\n\nTo learn more about the element system, please read the [element module documentation](.\u002Felement\u002Findex.html).\n\n```rust\nuse plotters::prelude::*;\nfn main() -> Result\u003C(), Box\u003Cdyn std::error::Error>> {\n    let root = BitMapBackend::new(\"plotters-doc-data\u002F3.png\", (300, 200)).into_drawing_area();\n    root.fill(&WHITE)?;\n    \u002F\u002F Draw an circle on the drawing area\n    root.draw(&Circle::new(\n        (100, 100),\n        50,\n        Into::\u003CShapeStyle>::into(&GREEN).filled(),\n    ))?;\n    root.present()?;\n    Ok(())\n}\n```\n\n![](https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002F3.png)\n\n### Composable Elements\n\nBesides the built-in elements, elements can be composed into a logical group we called composed elements.\nWhen composing new elements, the upper-left corner is given in the target coordinate, and a new pixel-based \ncoordinate which has the upper-left corner defined as `(0,0)` is used for further element composition.\n\nFor example, we can have an element which includes a dot and its coordinate.\n\n```rust\nuse plotters::prelude::*;\nuse plotters::coord::types::RangedCoordf32;\n\nfn main() -> Result\u003C(), Box\u003Cdyn std::error::Error>> {\n    let root = BitMapBackend::new(\"plotters-doc-data\u002F4.png\", (640, 480)).into_drawing_area();\n\n    root.fill(&RGBColor(240, 200, 200))?;\n\n    let root = root.apply_coord_spec(Cartesian2d::\u003CRangedCoordf32, RangedCoordf32>::new(\n        0f32..1f32,\n        0f32..1f32,\n        (0..640, 0..480),\n    ));\n\n    let dot_and_label = |x: f32, y: f32| {\n        return EmptyElement::at((x, y))\n            + Circle::new((0, 0), 3, ShapeStyle::from(&BLACK).filled())\n            + Text::new(\n                format!(\"({:.2},{:.2})\", x, y),\n                (10, 0),\n                (\"sans-serif\", 15.0).into_font(),\n            );\n    };\n\n    root.draw(&dot_and_label(0.5, 0.6))?;\n    root.draw(&dot_and_label(0.25, 0.33))?;\n    root.draw(&dot_and_label(0.8, 0.8))?;\n    root.present()?;\n    Ok(())\n}\n```\n\n![](https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002F4.png)\n\n### Chart Context\n\nIn order to draw a chart, Plotters needs a data object built on top of the drawing area called `ChartContext`.\nThe chart context defines even higher level constructs compare to the drawing area.\nFor example, you can define the label areas, meshes, and put a data series onto the drawing area with the help\nof the chart context object.\n\n```rust\nuse plotters::prelude::*;\nfn main() -> Result\u003C(), Box\u003Cdyn std::error::Error>> {\n    let root = BitMapBackend::new(\"plotters-doc-data\u002F5.png\", (640, 480)).into_drawing_area();\n    root.fill(&WHITE);\n    let root = root.margin(10, 10, 10, 10);\n    \u002F\u002F After this point, we should be able to construct a chart context\n    let mut chart = ChartBuilder::on(&root)\n        \u002F\u002F Set the caption of the chart\n        .caption(\"This is our first plot\", (\"sans-serif\", 40).into_font())\n        \u002F\u002F Set the size of the label region\n        .x_label_area_size(20)\n        .y_label_area_size(40)\n        \u002F\u002F Finally attach a coordinate on the drawing area and make a chart context\n        .build_cartesian_2d(0f32..10f32, 0f32..10f32)?;\n\n    \u002F\u002F Then we can draw a mesh\n    chart\n        .configure_mesh()\n        \u002F\u002F We can customize the maximum number of labels allowed for each axis\n        .x_labels(5)\n        .y_labels(5)\n        \u002F\u002F We can also change the format of the label text\n        .y_label_formatter(&|x| format!(\"{:.3}\", x))\n        .draw()?;\n\n    \u002F\u002F And we can draw something in the drawing area\n    chart.draw_series(LineSeries::new(\n        vec![(0.0, 0.0), (5.0, 5.0), (8.0, 7.0)],\n        &RED,\n    ))?;\n    \u002F\u002F Similarly, we can draw point series\n    chart.draw_series(PointSeries::of_element(\n        vec![(0.0, 0.0), (5.0, 5.0), (8.0, 7.0)],\n        5,\n        &RED,\n        &|c, s, st| {\n            return EmptyElement::at(c)    \u002F\u002F We want to construct a composed element on-the-fly\n            + Circle::new((0,0),s,st.filled()) \u002F\u002F At this point, the new pixel coordinate is established\n            + Text::new(format!(\"{:?}\", c), (10, 0), (\"sans-serif\", 10).into_font());\n        },\n    ))?;\n    root.present()?;\n    Ok(())\n}\n```\n\n![](https:\u002F\u002Fplotters-rs.github.io\u002Fplotters-doc-data\u002F5.png)\n\n## Misc\n\n### Development Version\n\nFind the latest development version of Plotters on [GitHub](https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters.git).\nClone the repository and learn more about the Plotters API and ways to contribute. Your help is needed!\n\nIf you want to add the development version of Plotters to your project, add the following to your `Cargo.toml`:\n\n```toml\n[dependencies]\nplotters = { git = \"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters.git\" }\n```\n\n### Reducing Depending Libraries && Turning Off Backends\nPlotters now supports use features to control the backend dependencies. By default, `BitMapBackend` and `SVGBackend` are supported,\nuse `default-features = false` in the dependency description in `Cargo.toml` and you can cherry-pick the backend implementations.\n\n- `svg` Enable the `SVGBackend`\n- `bitmap` Enable the `BitMapBackend`\n\nFor example, the following dependency description would avoid compiling with bitmap support:\n\n```toml\n[dependencies]\nplotters = { git = \"https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters.git\", default-features = false, features = [\"svg\"] }\n```\n\nThe library also allows consumers to make use of the [`Palette`](https:\u002F\u002Fcrates.io\u002Fcrates\u002Fpalette\u002F) crate's color types by default.\nThis behavior can also be turned off by setting `default-features = false`.\n\n### List of Features\n\nThis is the full list of features that is defined by `Plotters` crate. \nUse `default-features = false` to disable those default enabled features,\nand then you should be able to cherry-pick what features you want to include into `Plotters` crate. \nBy doing so, you can minimize the number of dependencies down to only `itertools` and compile time is less than 6s.\n\nThe following list is a complete list of features that can be opted in or out.\n\n- Tier 1 drawing backends\n\n| Name    |  Description | Additional Dependency |Default?|\n|---------|--------------|--------|------------|\n| bitmap\\_encoder  | Allow `BitMapBackend` to save the result to bitmap files | image, rusttype, font-kit | Yes |\n| svg\\_backend     | Enable `SVGBackend` Support | None | Yes |\n| bitmap\\_gif| Opt-in GIF animation Rendering support for `BitMapBackend`, implies `bitmap` enabled | gif | Yes |\n\n- Font manipulation features\n\n| Name     | Description                              | Additional Dependency | Default? |\n|----------|------------------------------------------|-----------------------|----------|\n| ttf      | Allows TrueType font support             | font-kit              | Yes      |\n| ab_glyph | Skips loading system fonts, unlike `ttf` | ab_glyph              | No       |\n\n`ab_glyph` supports TrueType and OpenType fonts, but does not attempt to\nload fonts provided by the system on which it is running.\nIt is pure Rust, and easier to cross compile.\nTo use this, you *must* call `plotters::style::register_font` before\nusing any `plotters` functions which require the ability to render text.\nThis function only exists when the `ab_glyph` feature is enabled.\n```rust,ignore\n\u002F\u002F\u002F Register a font in the fonts table.\n\u002F\u002F\u002F\n\u002F\u002F\u002F The `name` parameter gives the name this font shall be referred to\n\u002F\u002F\u002F in the other APIs, like `\"sans-serif\"`.\n\u002F\u002F\u002F\n\u002F\u002F\u002F Unprovided font styles for a given name will fallback to `FontStyle::Normal`\n\u002F\u002F\u002F if that is available for that name, when other functions lookup fonts which\n\u002F\u002F\u002F are registered with this function.\n\u002F\u002F\u002F\n\u002F\u002F\u002F The `bytes` parameter should be the complete contents\n\u002F\u002F\u002F of an OpenType font file, like:\n\u002F\u002F\u002F ```ignore\n\u002F\u002F\u002F include_bytes!(\"FiraGO-Regular.otf\")\n\u002F\u002F\u002F ```\npub fn register_font(\n    name: &str,\n    style: FontStyle,\n    bytes: &'static [u8],\n) -> Result\u003C(), InvalidFont>\n```\n\n- (De)serialization features\n\n| Name          | Description                              | Additional Dependency | Default? |\n|---------------|------------------------------------------|-----------------------|----------|\n| serialization | Enables serde (de)serialization support  | serde                 | No       |\n\n`serialization` enables support for serializing and deserializing using the serde crate.\nEnable the feature via Cargo.toml then use it like the following:\n```rust,ignore\n#[cfg(feature = \"serialization\")]\nuse serde::{Deserialize, Serialize};\n\n#[cfg_attr(feature = \"serialization\", derive(Serialize, Deserialize))]\npub struct RGBAColor(pub u8, pub u8, pub u8, pub f64);\n```\n\n- Coordinate features\n\n| Name    |  Description | Additional Dependency |Default?|\n|---------|--------------|--------|------------|\n| datetime | Enable the date and time coordinate support | chrono | Yes |\n\n- Element, series and util functions\n\n| Name    |  Description | Additional Dependency |Default?|\n|---------|--------------|--------|------------|\n| errorbar | The errorbar element support | None | Yes |\n| candlestick | The candlestick element support | None | Yes |\n| boxplot | The boxplot element support | None | Yes |\n| area\\_series | The area series support | None | Yes |\n| line\\_series | The line series support | None | Yes |\n| histogram | The histogram series support | None | Yes |\n| point\\_series| The point series support | None | Yes |\n\n- Misc\n\n| Name    |  Description | Additional Dependency |Default?|\n|---------|--------------|--------|------------|\n| deprecated\\_items | This feature allows use of deprecated items which is going to be removed in the future | None | Yes |\n| debug | Enable the code used for debugging | None | No |\n\n\n## FAQ List\n\n* Why does the WASM example break on my machine ?\n\n\tThe WASM example requires using `wasm32` target to build. Using `cargo build` is likely to use the default target\n\twhich in most of the case is any of the x86 target. Thus you need add `--target=wasm32-unknown-unknown` in the cargo\n\tparameter list  to build it. \n\n* How to draw text\u002Fcircle\u002Fpoint\u002Frectangle\u002F... on the top of chart ?\n\t\n\tAs you may have realized, Plotters is a drawing library rather than a traditional data plotting library, \n\tyou have the freedom to draw anything you want on the drawing area.\n\tUse `DrawingArea::draw` to draw any element on the drawing area. \n\n* Where can I find the backend code ?\n\t\n\tSince Plotters 0.3, all drawing backends are independent crate from the main Plotters crate.\n\tUse the following link to find the backend code:\n\n\t- [Bitmap Backend](.\u002Fplotters-bitmap\u002F) (current repository)\n\t- [SVG Backend](.\u002Fplotters-svg\u002F) (current repository)\n\t- [HTML5 Canvas Backend](https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters-canvas.git)\n\t- [GTK\u002FCairo Backend](https:\u002F\u002Fgithub.com\u002Fplotters-rs\u002Fplotters-cairo.git)\n\n* How to check if a backend writes to a file successfully ?\n\n\tThe behavior of Plotters backend is consistent with the standard library. \n    When the backend instance is dropped, [`crate::drawing::DrawingArea::present()`] or `Backend::present()` is called automatically \n    whenever is needed. When the `present()` method is called from `drop`, any error will be silently ignored.\n\n    In the case that error handling is important, you need manually call the `present()` method before the backend gets dropped.\n\tFor more information, please see the examples.\n\n\n","Plotters 是一个专注于数据绘图的 Rust 绘图库，支持 WASM 和原生应用。它提供了高质量的数据可视化功能，包括图表、曲线图和直方图等，并且能够兼容多种后端，如位图、矢量图、Piston 窗口、GTK\u002FCairo 以及 WebAssembly。Plotters 的设计注重灵活性与性能，使得开发者能够在不同平台上轻松创建复杂的图形。该库特别适用于需要进行科学计算结果展示、数据分析报告生成或在线交互式数据可视化的场景。",2,"2026-06-11 03:05:06","top_language"]