{"id":13478418,"url":"https://github.com/plotters-rs/plotters","last_synced_at":"2025-05-12T00:55:07.992Z","repository":{"id":36994605,"uuid":"183275571","full_name":"plotters-rs/plotters","owner":"plotters-rs","description":"A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely 🦀 📈🚀","archived":false,"fork":false,"pushed_at":"2025-03-27T17:55:35.000Z","size":7846,"stargazers_count":4172,"open_issues_count":155,"forks_count":300,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-05-12T00:54:59.612Z","etag":null,"topics":["data-plotting","graphing","plot","plotting","rust","rust-crate","science","visualization","webassembly"],"latest_commit_sha":null,"homepage":"https://plotters-rs.github.io/home/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plotters-rs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-04-24T17:23:56.000Z","updated_at":"2025-05-10T07:04:51.000Z","dependencies_parsed_at":"2023-01-17T12:01:31.496Z","dependency_job_id":"b463d2ec-6fcd-4997-99a8-abc39f9995ba","html_url":"https://github.com/plotters-rs/plotters","commit_stats":{"total_commits":1291,"total_committers":108,"mean_commits":"11.953703703703704","dds":"0.28582494190549956","last_synced_commit":"1f174c8b8e4b9dbcb160536228510515031d4609"},"previous_names":["38/plotters"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotters-rs%2Fplotters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotters-rs%2Fplotters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotters-rs%2Fplotters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotters-rs%2Fplotters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plotters-rs","download_url":"https://codeload.github.com/plotters-rs/plotters/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253655955,"owners_count":21943081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-plotting","graphing","plot","plotting","rust","rust-crate","science","visualization","webassembly"],"created_at":"2024-07-31T16:01:56.740Z","updated_at":"2025-05-12T00:55:07.964Z","avatar_url":"https://github.com/plotters-rs.png","language":"Rust","funding_links":[],"categories":["Rust","Libraries","库 Libraries","Scientific Computation","Data Science"],"sub_categories":["Data visualization","数据可视化 Data visualization","Visualization"],"readme":"# Plotters - A Rust drawing library focusing on data plotting for both WASM and native applications 🦀📈🚀\n\n\u003ca href=\"https://crates.io/crates/plotters\"\u003e\n    \u003cimg style=\"display: inline!important\" src=\"https://img.shields.io/crates/v/plotters.svg\"\u003e\u003c/img\u003e\n\u003c/a\u003e\n\u003ca href=\"https://docs.rs/plotters\"\u003e\n    \u003cimg style=\"display: inline!important\" src=\"https://docs.rs/plotters/badge.svg\"\u003e\u003c/img\u003e\n\u003c/a\u003e\n\u003ca href=\"https://docs.rs/plotters\"\u003e\n    \u003cimg style=\"display: inline!important\" src=\"https://img.shields.io/crates/d/plotters\"\u003e\u003c/img\u003e\n\u003c/a\u003e\n\u003ca href=\"https://plotters-rs.github.io/rustdoc/plotters/\"\u003e\n\t\u003cimg style=\"display: inline! important\" src=\"https://img.shields.io/badge/docs-development-lightgrey.svg\"\u003e\u003c/img\u003e\n\u003c/a\u003e\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/Cairo and WebAssembly. \n\n- A new Plotters Developer's Guide is a work in progress. The preview version is available [here](https://plotters-rs.github.io/book).\n- Try Plotters with an interactive Jupyter notebook, or view [here](https://plotters-rs.github.io/plotters-doc-data/evcxr-jupyter-integration.html) for the static HTML version.\n- To view the WASM example, go to this [link](https://plotters-rs.github.io/wasm-demo/www/index.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://github.com/plotters-rs/plotters/blob/master/plotters/examples/console.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://github.com/plotters-rs/plotters/blob/master/plotters/examples/chart.rs\"\u003e\n    \u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/sample.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/stock.rs\"\u003e\n    \u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/stock.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/histogram.rs\"\u003e\n    \u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/histogram.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters#quick-start\"\u003e\n    \u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/0.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"#\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/console-2.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/mandelbrot.rs\"\u003e\n    \u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/mandelbrot.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters#trying-with-jupyter-evcxr-kernel-interactively\"\u003e\n    \u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/evcxr_animation.gif\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\n\u003ca href=\"https://github.com/plotters-rs/plotters-piston/blob/master/examples/cpustat.rs\"\u003e\n    \u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/plotters-piston.gif\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/normal-dist.rs\"\u003e\n    \u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/normal-dist.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/two-scales.rs\"\u003e\n    \u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/twoscale.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/matshow.rs\"\u003e\n    \u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/matshow.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/sierpinski.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/sierpinski.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/normal-dist2.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/normal-dist2.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/errorbar.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/errorbar.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/slc-temp.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/slc-temp.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/area-chart.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/area-chart.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/snowflake.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/snowflake.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/animation.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/animation.gif\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/console.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/console-example.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/console.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/console.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/blit-bitmap.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/blit-bitmap.png\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/boxplot.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/boxplot.svg\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/3d-plot.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/3d-plot.svg\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/3d-plot2.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/3d-plot2.gif\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/plotters-rs/plotters/blob/master/plotters/examples/tick_control.rs\"\u003e\n\t\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/tick_control.svg\" class=\"galleryItem\" width=200px\u003e\u003c/img\u003e\n\u003c/a\u003e\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 \u0026\u0026 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\u003e/plotters-doc-data`\n\nAnd the following code draws a quadratic function. `src/main.rs` writes the chart to `plotters-doc-data/0.png`\n\n```rust\nuse plotters::prelude::*;\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let root = BitMapBackend::new(\"plotters-doc-data/0.png\", (640, 480)).into_drawing_area();\n    root.fill(\u0026WHITE)?;\n    let mut chart = ChartBuilder::on(\u0026root)\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 / 50.0).map(|x| (x, x * x)),\n            \u0026RED,\n        ))?\n        .label(\"y = x^2\")\n        .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], \u0026RED));\n\n    chart\n        .configure_series_labels()\n        .background_style(\u0026WHITE.mix(0.8))\n        .border_style(\u0026BLACK)\n        .draw()?;\n\n    root.present()?;\n\n    Ok(())\n}\n```\n\n![](https://plotters-rs.github.io/plotters-doc-data/0.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://github.com/plotters-rs/plotters-wasm-demo)\n- minifb + Plotters: [plotters-minifb-demo](https://github.com/plotters-rs/plotters-minifb-demo)\n- GTK + Plotters: [plotters-gtk-demo](https://github.com/plotters-rs/plotters-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(\u0026WHITE)?;\n    let mut chart = ChartBuilder::on(\u0026root)\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 / 50.0).map(|x| (x, x * x)),\n        \u0026RED,\n    )).unwrap()\n        .label(\"y = x^2\")\n        .legend(|(x,y)| PathElement::new(vec![(x,y), (x + 20,y)], \u0026RED));\n\n    chart.configure_series_labels()\n        .background_style(\u0026WHITE.mix(0.8))\n        .border_style(\u0026BLACK)\n        .draw()?;\n    Ok(())\n});\nfigure\n```\n\n\u003cimg src=\"https://plotters-rs.github.io/plotters-doc-data/evcxr_animation.gif\" width=\"450px\"\u003e\u003c/img\u003e\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://github.com/google/evcxr/tree/master/evcxr_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://github.com/38/plotters-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://plotters-rs.github.io/plotters-doc-data/evcxr-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://github.com/plotters-rs/plotters-wasm-demo). \nTo play with the deployed version, follow this [link](https://plotters-rs.github.io/wasm-demo/www/index.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() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    // Create a 800*600 bitmap and start drawing\n    let mut backend = BitMapBackend::new(\"plotters-doc-data/1.png\", (300, 200));\n    // And if we want SVG backend\n    // let mut backend = SVGBackend::new(\"output.svg\", (800, 600));\n    backend.draw_rect((50, 50), (200, 150), \u0026RED, true)?;\n    backend.present()?;\n    Ok(())\n}\n```\n\n![](https://plotters-rs.github.io/plotters-doc-data/1.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() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let root_drawing_area =\n        BitMapBackend::new(\"plotters-doc-data/2.png\", (300, 200)).into_drawing_area();\n    // And we can split the drawing area into 3x3 grid\n    let child_drawing_areas = root_drawing_area.split_evenly((3, 3));\n    // Then we fill the drawing area with different color\n    for (area, color) in child_drawing_areas.into_iter().zip(0..) {\n        area.fill(\u0026Palette99::pick(color))?;\n    }\n    root_drawing_area.present()?;\n    Ok(())\n}\n```\n\n![](https://plotters-rs.github.io/plotters-doc-data/2.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](./element/index.html).\n\n```rust\nuse plotters::prelude::*;\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let root = BitMapBackend::new(\"plotters-doc-data/3.png\", (300, 200)).into_drawing_area();\n    root.fill(\u0026WHITE)?;\n    // Draw an circle on the drawing area\n    root.draw(\u0026Circle::new(\n        (100, 100),\n        50,\n        Into::\u003cShapeStyle\u003e::into(\u0026GREEN).filled(),\n    ))?;\n    root.present()?;\n    Ok(())\n}\n```\n\n![](https://plotters-rs.github.io/plotters-doc-data/3.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() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let root = BitMapBackend::new(\"plotters-doc-data/4.png\", (640, 480)).into_drawing_area();\n\n    root.fill(\u0026RGBColor(240, 200, 200))?;\n\n    let root = root.apply_coord_spec(Cartesian2d::\u003cRangedCoordf32, RangedCoordf32\u003e::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(\u0026BLACK).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(\u0026dot_and_label(0.5, 0.6))?;\n    root.draw(\u0026dot_and_label(0.25, 0.33))?;\n    root.draw(\u0026dot_and_label(0.8, 0.8))?;\n    root.present()?;\n    Ok(())\n}\n```\n\n![](https://plotters-rs.github.io/plotters-doc-data/4.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() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let root = BitMapBackend::new(\"plotters-doc-data/5.png\", (640, 480)).into_drawing_area();\n    root.fill(\u0026WHITE);\n    let root = root.margin(10, 10, 10, 10);\n    // After this point, we should be able to construct a chart context\n    let mut chart = ChartBuilder::on(\u0026root)\n        // Set the caption of the chart\n        .caption(\"This is our first plot\", (\"sans-serif\", 40).into_font())\n        // Set the size of the label region\n        .x_label_area_size(20)\n        .y_label_area_size(40)\n        // Finally attach a coordinate on the drawing area and make a chart context\n        .build_cartesian_2d(0f32..10f32, 0f32..10f32)?;\n\n    // Then we can draw a mesh\n    chart\n        .configure_mesh()\n        // We can customize the maximum number of labels allowed for each axis\n        .x_labels(5)\n        .y_labels(5)\n        // We can also change the format of the label text\n        .y_label_formatter(\u0026|x| format!(\"{:.3}\", x))\n        .draw()?;\n\n    // 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        \u0026RED,\n    ))?;\n    // 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        \u0026RED,\n        \u0026|c, s, st| {\n            return EmptyElement::at(c)    // We want to construct a composed element on-the-fly\n            + Circle::new((0,0),s,st.filled()) // 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://plotters-rs.github.io/plotters-doc-data/5.png)\n\n## Misc\n\n### Development Version\n\nFind the latest development version of Plotters on [GitHub](https://github.com/plotters-rs/plotters.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://github.com/plotters-rs/plotters.git\" }\n```\n\n### Reducing Depending Libraries \u0026\u0026 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://github.com/plotters-rs/plotters.git\", default-features = false, features = [\"svg\"] }\n```\n\nThe library also allows consumers to make use of the [`Palette`](https://crates.io/crates/palette/) 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/// Register a font in the fonts table.\n///\n/// The `name` parameter gives the name this font shall be referred to\n/// in the other APIs, like `\"sans-serif\"`.\n///\n/// Unprovided font styles for a given name will fallback to `FontStyle::Normal`\n/// if that is available for that name, when other functions lookup fonts which\n/// are registered with this function.\n///\n/// The `bytes` parameter should be the complete contents\n/// of an OpenType font file, like:\n/// ```ignore\n/// include_bytes!(\"FiraGO-Regular.otf\")\n/// ```\npub fn register_font(\n    name: \u0026str,\n    style: FontStyle,\n    bytes: \u0026'static [u8],\n) -\u003e Result\u003c(), InvalidFont\u003e\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/circle/point/rectangle/... 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](./plotters-bitmap/) (current repository)\n\t- [SVG Backend](./plotters-svg/) (current repository)\n\t- [HTML5 Canvas Backend](https://github.com/plotters-rs/plotters-canvas.git)\n\t- [GTK/Cairo Backend](https://github.com/plotters-rs/plotters-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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplotters-rs%2Fplotters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplotters-rs%2Fplotters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplotters-rs%2Fplotters/lists"}