{"id":13734425,"url":"https://github.com/elftausend/graplot","last_synced_at":"2025-04-11T03:52:37.761Z","repository":{"id":38972801,"uuid":"480949134","full_name":"elftausend/graplot","owner":"elftausend","description":"Plotting library written in Rust","archived":false,"fork":false,"pushed_at":"2024-02-27T20:34:10.000Z","size":1769,"stargazers_count":29,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T03:52:31.260Z","etag":null,"topics":["3d-plotting","bars","chart","charting-library","charts","data-visualization","graphing","graphs","macroquad","matplotlib","plot","plots","plotting","rust","visualization"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elftausend.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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}},"created_at":"2022-04-12T19:39:14.000Z","updated_at":"2025-03-13T19:45:44.000Z","dependencies_parsed_at":"2024-02-27T21:51:36.985Z","dependency_job_id":null,"html_url":"https://github.com/elftausend/graplot","commit_stats":{"total_commits":154,"total_committers":2,"mean_commits":77.0,"dds":"0.045454545454545414","last_synced_commit":"278091534789a83188c634d5ba58e2639154b32a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elftausend%2Fgraplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elftausend%2Fgraplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elftausend%2Fgraplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elftausend%2Fgraplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elftausend","download_url":"https://codeload.github.com/elftausend/graplot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339261,"owners_count":21087214,"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":["3d-plotting","bars","chart","charting-library","charts","data-visualization","graphing","graphs","macroquad","matplotlib","plot","plots","plotting","rust","visualization"],"created_at":"2024-08-03T03:00:55.586Z","updated_at":"2025-04-11T03:52:37.737Z","avatar_url":"https://github.com/elftausend.png","language":"Rust","readme":"# graplot\n\n[![Crates.io version](https://img.shields.io/crates/v/graplot.svg)](https://crates.io/crates/graplot)\n[![Docs](https://docs.rs/graplot/badge.svg?version=0.1.22)](https://docs.rs/graplot/0.1.22/graplot/)\n\n'graplot' is an experimental plotting library written in Rust that is based on [macroquad] (internally [litequad]).\nIt creates a window displaying the graphs.\n\n[macroquad]: https://github.com/elftausend/macroquad\n[litequad]: https://github.com/elftausend/litequad\n\n## Installation\n\nAdd 'graplot' as a dependency:\n```toml\n[dependencies]\ngraplot = \"0.1.22\"\n```\n\n## [Examples]\n\n[Examples]: https://github.com/elftausend/graplot/tree/main/examples\n\n```rust\nuse graplot::Plot;\n\nlet plot = Plot::new([-4., -2., 1., 4.]);\nplot.show();\n```\n\n\u003cimg src=\"pictures/plot1.png\" alt=\"first plot example\" width=\"350\"/\u003e\n\n\n3D line plot:\n\n```rust\nuse graplot::Plot3D;\n\nlet xs = [0.,1.,2.,3.,4.,5.,6.];\nlet ys = [0.,1.,4.,9.,16.,25.,36.];\nlet zs = [0.,1.,4.,9.,16.,25.,36.];\n\n// move with: W, A, S, D\nlet plot = Plot3D::new((xs, ys, zs, \"r-o\"));\nplot.show();\n```\n\n\n\u003cimg src=\"pictures/3d_line.png\" alt=\"3d line plot example\" width=\"350\"/\u003e\n\nMultiple graphs:\n```rust\nuse graplot::Plot;\n\nlet xs = [1., 2., 3.,];\nlet ys = [1.7, 3., 1.9];\n\nlet ys1 = [1.4, 1.6, 1.5];    \n\nlet ys2 = [0.9, 1.2, 1.7, 1.9, 2.];    \n\nlet mut plot = Plot::new((xs, ys));\nplot.add((xs, ys1, \"c-o\"));\nplot.add((ys2, \"r-\"));\nplot.show();\n```\n\n\u003cimg src=\"pictures/multiple.png\" alt=\"multiple graphs\" width=\"350\"/\u003e\n\nLabel the x and y axis and set a title:\n\n```rust\nuse graplot::{x, Plot};\n\nlet mut plot = Plot::new((|x: f64| x.cos(), x(6.)));\n\nplot.set_title(\"cosine wave\");\n\nplot.set_xlabel(\"x axis\");\nplot.set_ylabel(\"y axis\");\nplot.show();\n```\n\u003cimg src=\"pictures/cosine_labeled.png\" alt=\"cosine labeled\" width=\"350\"/\u003e\n\n[Collatz Conjecture]:\n\n[Collatz Conjecture]: https://github.com/elftausend/graplot/blob/main/examples/collatz.rs\n\n\u003cimg src=\"pictures/collatz.png\" alt=\"collatz conjecture\" width=\"400\"/\u003e\n\nDraw pie charts:\n\n```rust\nuse graplot::Pie;\n\n// without labels: let pie = Pie::new([35., 25., 25., 15.]);\nlet draw = [(35., \"label\"), (25., \"len\"), (25., \"labeled\"), (15., \"test\")];\nlet pie = Pie::new(draw);\npie.show();\n```\n\u003cimg src=\"pictures/pie_chart.png\" alt=\"pie chart\" width=\"350\"/\u003e\n\nSine wave:\n```rust\nuse graplot::Plot;\n\nlet mut xs = [0.; 1000]; \n\nlet mut add = 0f64;\nfor idx in 0..1000 {\n    xs[idx] = add/1000.;\n    add += 1.;\n}\n    \nlet mut ys = [0.; 1000];\nfor (i, y) in ys.iter_mut().enumerate() {\n    *y = (2. * std::f64::consts::PI * xs[i]).sin();\n}\n// or alternatively: let plot = Plot::new((|x: f64| x.sin(), x(4.)));\nlet plot = Plot::new((xs, ys));\nplot.show();\n```\n\n\u003cimg src=\"pictures/sine_wave.png\" alt=\"sine wave example\" width=\"350\"/\u003e\n\n\nx³ + x² - 0.08:\n```rust\nuse graplot::{Plot, x};\n\n// x(...) ... sets the absolute max value for x \nlet plot = Plot::new((|x: f64| x.powf(3.) + x.powf(2.) - 0.08, x(1.)) );\nplot.show();\n```\n\u003cimg src=\"pictures/pol3.png\" alt=\"pol3\" width=\"350\"/\u003e\n\n\nx² - 0.5:\n```rust\nuse graplot::Plot;\n\nlet plot = Plot::new(|x: f64| x.powf(2.) - 0.5);\nplot.show();\n```\n\n\u003cimg src=\"pictures/x2.png\" alt=\"x squared example\" width=\"350\"/\u003e\n\nUse the Polynomial struct or polynomial() function to create a polynomial function that runs through all given points:\n\n```rust\nuse graplot::{x, Plot, Polynomial};\n\nlet poly = Polynomial::new(\u0026[2., 3., 1.], \u0026[2., 3., 2.]);\nlet plot = Plot::new((poly, x(10.)));\nplot.show();\n```\n\n\u003cimg src=\"pictures/through_points.png\" alt=\"polynomial functions runs through 3 points\" width=\"350\"/\u003e\n\nDraw bar graphs:\n\n```rust\nuse graplot::Bar;\n\nlet mut bar = Bar::new([\"Ferris\", \"Stefan\", \"Test\"], \u0026[100., 200., 700.]);\nbar.set_title(\"title\");\nbar.set_xlabel(\"test\");\nbar.show();\n```\n\n\u003cimg src=\"pictures/bars.png\" alt=\"bar graph\" width=\"300\"/\u003e\n\nUsing a line description: (matplotlib)\n\n```rust\nuse graplot::Plot;\n\n// c ... cyan color, - ... solid line, o ... ring marker\nlet plot = Plot::new(([-4., -3., -3.4, -3.75, -4.1], \"c-o\"));\nplot.show();\n```\n\n\u003cimg src=\"pictures/line_desc.png\" alt=\"line desc example\" width=\"250\"/\u003e\n\nDraw graphs with nodes and egdes:\n\n```rust\nuse graplot::{Graph, RED, graph::GraphDesc, Color};\n\nlet mut graph = Graph::new();\ngraph.graph_desc = GraphDesc {\n    node_color: RED,\n    outer_ring: (Color::new(1., 0.5, 0.8, 1.), 3.5),\n    ..Default::default()\n};\nlet a = graph.add_node(vec![]);\nlet b = graph.add_node(vec![]);\nlet c = graph.add_node(vec![]);\n\nlet d = graph.add_node(vec![a.idx, b.idx]);\nlet e = graph.add_node(vec![a.idx, c.idx]);\n\ngraph.add_node(vec![d.idx, e.idx, b.idx]);\n\ngraph.show();\n```\n\n\u003cimg src=\"pictures/graph.png\" alt=\"graph\" width=\"300\"/\u003e\n\nCustom scaling:\n\n```rust\nuse graplot::{Desc, Plot, x};\n\nlet mut plot = Plot::new((|x: f64| x.cos(), x(2.)));\nplot.set_desc(Desc {\n    min_steps_x: 6.,\n    spacing_x: 47.,\n    ..Default::default()\n});\nplot.show();\n```\n\n\nSpawning multiple windows on linux (currently not working):\n\n```rust\nlet mut plot = Plot::new(|x: f64| x.powf(3.) + x.powf(2.) - 0.08);\nplot.set_title(\"x^3 + x^2 - 0.08\");\nlet h = plot.show_threaded() // show_threaded() is currently linux only;\n\nlet mut plot = Plot::new(|x: f64| x.powf(2.) + 0.08);\nplot.set_title(\"x²\");\nplot.show();\n\nh.join().unwrap() // you need to close both windows\n```\n\n\u003cimg src=\"pictures/multiple_windows.png\" alt=\"multiple windows\" width=\"500\"/\u003e\n\n## Changelog\n\n- 0.1.22: added ToF64\n- 0.1.22: added graphs (nodes, edges)\n- 0.1.19: negative value bars\n- 0.1.18: bugfixes\n- 0.1.17: basic 3d plotting\n- 0.1.16: coloring,\n- 0.1.15: easier colored bars\n- 0.1.14: ???\n- 0.1.13: added pie charts\n- 0.1.12: added bar graphs\n- 0.1.11: added scatter plots\n- 0.1.10: create polynomial functions with a set of points\n- 0.1.9: fixed bug\n- 0.1.8: set color now uses 3 args, fixed step size\n- 0.1.7: Set graph color, custom x \u0026 y \"line\" spacing and step size | \"custom scaling\"\n- 0.1.6: Label x axis, litequad\n- 0.1.5: y axis, set title, /*mutliple windows on linux*/ | yanked\n- 0.1.4: Multiple graphs","funding_links":[],"categories":["Libraries"],"sub_categories":["Libraries: Other"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felftausend%2Fgraplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felftausend%2Fgraplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felftausend%2Fgraplot/lists"}