Skip to content

Commit

Permalink
adding simple plot of rust data structures
Browse files Browse the repository at this point in the history
  • Loading branch information
noahgift committed Jul 11, 2023
1 parent 3542f32 commit d97ca8a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions graph-visualize/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "graph-visualize"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rasciigraph = "0.2.0"
13 changes: 13 additions & 0 deletions graph-visualize/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
format:
cargo fmt --quiet

lint:
cargo clippy --quiet

test:
cargo test --quiet

run:
cargo run

all: format lint test run
21 changes: 21 additions & 0 deletions graph-visualize/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extern crate rasciigraph;

use rasciigraph::{plot, Config};

fn main() {
let cities = vec!["Lisbon", "Madrid", "Paris", "Berlin", "Copenhagen", "Stockholm", "Moscow"];
let distances_travelled = vec![0.0, 502.56, 1053.36, 2187.27, 2636.42, 3117.23, 4606.35];

println!("{}", cities.join(" > "));

println!(
"{}",
plot(
distances_travelled.into_iter().map(|d| d as f64).collect(),
Config::default()
.with_offset(10)
.with_height(10)
.with_caption("Travelled distances (km)".to_string())
)
);
}

0 comments on commit d97ca8a

Please sign in to comment.