use quill::prelude::*;
fn exponential_data() -> Vec<(f64, f64)> {
(0..=20)
.map(|x| {
let xf = x as f64;
(xf, 10.0_f64.powf(xf * 0.1)) })
.collect()
}
fn power_law_data() -> Vec<(f64, f64)> {
(1..=20)
.map(|x| {
let xf = x as f64;
(xf, xf.powi(3)) })
.collect()
}
fn main() {
let log_plot = Plot::builder()
.dimensions((800, 600))
.title("Logarithmic Y-Scale Example with Minor Ticks")
.x_label("Time")
.y_label("Value (Log Scale)")
.legend(Legend::TopLeftInside)
.grid(Grid::Solid)
.minor_grid(MinorGrid::YAxis)
.y_scale(Scale::Log)
.data([
Series::builder()
.name("10^(x/10)")
.color(Color::Red)
.data(exponential_data())
.marker(Marker::Circle)
.marker_size(4.0)
.line(Line::Solid)
.line_width(2.0)
.interpolation(Interpolation::Linear)
.build(),
Series::builder()
.name("x³")
.color(Color::Blue)
.data(power_law_data())
.marker(Marker::Square)
.marker_size(4.0)
.line(Line::Dashed)
.line_width(2.0)
.interpolation(Interpolation::Linear)
.build(),
])
.build();
match log_plot.to_svg("./gallery/logarithmic.svg") {
Ok(_) => println!("Logarithmic plot saved as SVG."),
Err(e) => eprintln!("Failed to save SVG: {}", e),
}
}