Ezel
  • Ezel
  • Basics
    • 1. Getting Started
    • 2. Concepts
      • Axis
    • 3. Attributes
    • 4. Cloud
  • Optimization
    • Style Customization
    • Data Lifetime
  • Grammar of Graphics
    • What is GoG
    • Interface
  • plot
    • PlainBox
    • Cartesian2
      • Basics
      • Geometry
    • Cartesian3
    • Text
    • NodeGraph
    • Grid
  • Git Repository
  • crates.io
  • docs.rs
  • pypi
  • Dev
    • Rendering
  • Coordinates
Powered by GitBook
On this page
  1. Optimization

Data Lifetime

PreviousStyle CustomizationNextWhat is GoG

Last updated 3 years ago

ezel retains user data in memory until the object is dropped.

for _ in 0..1000 {
    plot.scatter(random_million_points());
}
// plot has 1_000*1_000_000 points in memory

// layout and axis limits are determined from 1_000*1_000_000 points
plot.draw_to_file("large.png", (500, 500)).unwrap();

Sometimes it is desirable to save the memory by dumping the data onto the bitmap target and dropping the data immediately. ezel does not support this yet, meanwhile you can use library at the cost of manual specification of layouts and limits.

// Plotters example
use plotters::prelude::*;

let mut cc = ChartBuilder::on(&upper)
    .margin(5)
    .set_all_label_area_size(50)  // you should manually calculate this
    .caption("Sine and Cosine", ("sans-serif", 40))
    .build_cartesian_2d(-3.4f32..3.4, -1.2f32..1.2f32)?;

cc.configure_mesh()
    .x_labels(20)  // you should manually calculate this
    .y_labels(10)  // you should manually calculate this
    .disable_mesh()
    .x_label_formatter(&|v| format!("{:.1}", v))
    .y_label_formatter(&|v| format!("{:.1}", v))
    .draw()?;

plotters